-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24f042c
commit 0ca32a2
Showing
11 changed files
with
220 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test('has title', async ({ page }) => { | ||
await page.goto('./'); | ||
test('visit page and take screenshot', async ({ page }) => { | ||
const targetUrl = process.env.ENVIRONMENT_URL || 'https://www.mikeodnis.dev' | ||
|
||
await expect(page).toHaveTitle(/Mike Odnis/); | ||
}); | ||
const response = await page.goto(targetUrl) | ||
|
||
expect(response.status(),'should respond with correct status code').toBeLessThan(400) | ||
|
||
await page.screenshot({ path: 'screenshot.jpg' }) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { describe, it, expect, vi } from 'vitest'; | ||
import axios from 'axios'; | ||
import fetcher from './fetcher'; | ||
|
||
// Mock the axios module | ||
vi.mock('axios'); | ||
|
||
describe('fetcher', () => { | ||
it('should fetch data successfully', async () => { | ||
// Arrange: mock axios.get to return a resolved promise with some data | ||
const mockData = { id: 1, name: 'Test' }; | ||
(axios.get as any).mockResolvedValueOnce({ data: mockData }); | ||
|
||
// Act: call the fetcher function | ||
const result = await fetcher<{ id: number; name: string }>('https://api.example.com/data'); | ||
|
||
// Assert: verify the function returns the expected data | ||
expect(result).toEqual(mockData); | ||
expect(axios.get).toHaveBeenCalledWith('https://api.example.com/data', undefined); | ||
}); | ||
|
||
it('should handle axios errors', async () => { | ||
// Arrange: mock axios.get to reject with an error | ||
const mockError = new Error('Network Error'); | ||
(axios.get as any).mockRejectedValueOnce(mockError); | ||
|
||
// Act & Assert: verify that the fetcher function throws the same error | ||
await expect(fetcher('https://api.example.com/data')).rejects.toThrow('Network Error'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"status": "interrupted" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters