-
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.
chore: replace testing-library with playwright
- add playwright configuration - add authentication/authorization mocking with msal for component testing - add `ms-playwright.playwright` to vscode extension recommendations - remove jest and testing-libraries references - update test cases BREAKING CHANGE: use playwright instead of jest and testing-library for testing
- Loading branch information
1 parent
45dbf28
commit 973d42b
Showing
20 changed files
with
535 additions
and
82 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,9 @@ | |
|
||
# testing | ||
/coverage | ||
/playwright-report/ | ||
/playwright/.cache/ | ||
/test-results/ | ||
|
||
# production | ||
/build | ||
|
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,4 +1,5 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npm run test -- --onlyChanged --watchAll=false | ||
# Due to device performance, the tests are run only on one project and with increased timeout, while the tests stop immediately at the first failure. | ||
npm run test -- --project="Desktop Chromium" --timeout=30000 -x |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import type { PlaywrightTestConfig } from '@playwright/experimental-ct-react'; | ||
import { devices } from '@playwright/experimental-ct-react'; | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
const config: PlaywrightTestConfig = { | ||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: !!process.env.CI, | ||
|
||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: 'Desktop Chromium', | ||
use: { | ||
browserName: 'chromium', | ||
viewport: { height: 720, width: 1280 }, | ||
}, | ||
}, | ||
{ | ||
name: 'Desktop Safari', | ||
use: { | ||
browserName: 'webkit', | ||
viewport: { height: 720, width: 1280 }, | ||
}, | ||
}, | ||
{ | ||
name: 'Desktop Firefox', | ||
use: { | ||
browserName: 'firefox', | ||
viewport: { height: 720, width: 1280 }, | ||
}, | ||
}, | ||
{ | ||
name: 'Mobile Chrome', | ||
use: devices['Pixel 5'], | ||
}, | ||
{ | ||
name: 'Mobile Safari', | ||
use: devices['iPhone 13 Pro'], | ||
}, | ||
], | ||
|
||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: process.env.CI ? [['junit', { outputFile: 'build/test-results/test/component-test-results.xml' }]] : 'list', | ||
|
||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
|
||
/* The base directory, relative to the config file, for snapshot files created with toMatchSnapshot and toHaveScreenshot. */ | ||
snapshotDir: './__snapshots__', | ||
|
||
testDir: './src', | ||
|
||
/* Maximum time one test can run for (in milliseconds). */ | ||
timeout: 20_000, | ||
|
||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
/* Port to use for Playwright component endpoint. */ | ||
ctPort: 3100, | ||
|
||
ctViteConfig: { | ||
server: { | ||
open: false, | ||
}, | ||
}, | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
}, | ||
|
||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
}; | ||
|
||
export default config; |
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,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Testing Page</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/playwright/index.ts"></script> | ||
</body> | ||
</html> |
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,25 @@ | ||
import { setupIonicReact } from '@ionic/react'; | ||
import { setupMsalMock } from '../src/utils/test/setupMsalMock'; | ||
|
||
/* Core CSS required for Ionic components to work properly */ | ||
import '@ionic/react/css/core.css'; | ||
|
||
/* Basic CSS for apps built with Ionic */ | ||
import '@ionic/react/css/normalize.css'; | ||
import '@ionic/react/css/structure.css'; | ||
import '@ionic/react/css/typography.css'; | ||
|
||
/* Optional CSS utils that can be commented out */ | ||
import '@ionic/react/css/padding.css'; | ||
import '@ionic/react/css/float-elements.css'; | ||
import '@ionic/react/css/text-alignment.css'; | ||
import '@ionic/react/css/text-transformation.css'; | ||
import '@ionic/react/css/flex-utils.css'; | ||
import '@ionic/react/css/display.css'; | ||
|
||
/* Styles */ | ||
import '../src/theme/index.css'; | ||
|
||
setupIonicReact(); | ||
|
||
setupMsalMock(); |
Oops, something went wrong.