-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: use playwright for e2e tests with coverage 🔥😎🔥
- Loading branch information
Showing
13 changed files
with
2,115 additions
and
727 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { useState } from 'react'; | ||
|
||
import App, { images as baseImages } from './App'; | ||
|
||
/** | ||
* Wrapper to manipulate props on the component in E2E tests. | ||
* @NOTE This is only for internal testing, it is not required to use the library. | ||
*/ | ||
export const Test = () => { | ||
const [images, setImages] = useState(baseImages); | ||
const [initialImageIndex, setInitialImageIndex] = useState(0); | ||
|
||
return ( | ||
<> | ||
<App images={images} initialImageIndex={initialImageIndex} /> | ||
<div> | ||
<button | ||
onClick={() => | ||
setImages((prev) => | ||
prev.length == baseImages.length ? baseImages.slice(0, 12) : baseImages, | ||
) | ||
} | ||
> | ||
Toggle image set | ||
</button> | ||
|
||
<button | ||
onClick={() => setInitialImageIndex((prev) => (prev === 0 ? images.length - 1 : 0))} | ||
> | ||
Toggle initial index | ||
</button> | ||
</div> | ||
</> | ||
); | ||
}; |
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 |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
"author": "nerdyman", | ||
"license": "MIT", | ||
"sideEffects": false, | ||
"packageManager": "[email protected].3", | ||
"packageManager": "[email protected].9", | ||
"module": "dist/index.mjs", | ||
"typings": "dist/index.d.ts", | ||
"files": [ | ||
|
@@ -18,10 +18,12 @@ | |
], | ||
"scripts": { | ||
"bootstrap": "corepack disable && corepack enable && pnpm i --frozen-lockfile", | ||
"dev": "pnpm -r --stream run start", | ||
"dx": "npm run bootstrap && pnpm exec husky install", | ||
"start": "tsup --watch", | ||
"build": "tsup", | ||
"test": "jest", | ||
"test": "rm -rf {.nyc_output,coverage} && playwright test && pnpm nyc report --reporter=lcov", | ||
"test:debug": "env PWDEBUG=1 NODE_ENV=test playwright test && pnpm nyc report --reporter=lcov", | ||
"lint": "eslint . && prettier --check .", | ||
"prepare": "husky install", | ||
"prepublish": "pnpm run build", | ||
|
@@ -56,24 +58,33 @@ | |
"react": ">=16.8" | ||
}, | ||
"devDependencies": { | ||
"@babel/preset-react": "^7.16.7", | ||
"@babel/preset-typescript": "^7.16.7", | ||
"@playwright/test": "^1.21.1", | ||
"@size-limit/preset-small-lib": "^7.0.8", | ||
"@types/react": "^17.0.43", | ||
"@types/react-dom": "^17.0.14", | ||
"@typescript-eslint/eslint-plugin": "^5.18.0", | ||
"@typescript-eslint/parser": "^5.18.0", | ||
"eslint": "^8.12.0", | ||
"@types/jest-axe": "^3.5.3", | ||
"@types/react": "^18.0.6", | ||
"@types/react-dom": "^18.0.2", | ||
"@typescript-eslint/eslint-plugin": "^5.20.0", | ||
"@typescript-eslint/parser": "^5.20.0", | ||
"axe-core": "^4.4.1", | ||
"axe-playwright": "^1.1.11", | ||
"babel-plugin-istanbul": "^6.1.1", | ||
"esbuild-plugin-babel": "^0.2.3", | ||
"eslint": "^8.14.0", | ||
"eslint-plugin-react": "^7.29.4", | ||
"eslint-plugin-react-hooks": "^4.4.0", | ||
"eslint-plugin-testing-library": "^5.2.1", | ||
"husky": "^7.0.4", | ||
"lint-staged": "^12.3.7", | ||
"lint-staged": "^12.4.0", | ||
"nyc": "^15.1.0", | ||
"playwright-core": "^1.21.1", | ||
"prettier": "^2.6.2", | ||
"pretty-quick": "^3.1.3", | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2", | ||
"react": "^18.0.0", | ||
"react-dom": "^18.0.0", | ||
"size-limit": "^7.0.8", | ||
"tslib": "^2.3.1", | ||
"tsup": "^5.12.4", | ||
"tslib": "^2.4.0", | ||
"tsup": "^5.12.6", | ||
"typescript": "^4.6.3" | ||
} | ||
} |
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,38 @@ | ||
import { PlaywrightTestConfig, devices } from '@playwright/test'; | ||
|
||
const config: PlaywrightTestConfig = { | ||
forbidOnly: !!process.env.CI, | ||
retries: process.env.CI ? 2 : 0, | ||
testDir: './test', | ||
outputDir: './test/results', | ||
webServer: { | ||
command: 'pnpm run dev', | ||
url: 'http://localhost:3000', | ||
env: { | ||
NODE_ENV: 'test', | ||
USE_BABEL_PLUGIN_ISTANBUL: '1', | ||
}, | ||
}, | ||
use: { | ||
trace: 'on-first-retry', | ||
}, | ||
expect: { | ||
toMatchSnapshot: { threshold: 0.1 }, | ||
}, | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
// { | ||
// name: 'firefox', | ||
// use: { ...devices['Desktop Firefox'] }, | ||
// }, | ||
// { | ||
// name: 'webkit', | ||
// use: { ...devices['Desktop Safari'] }, | ||
// }, | ||
], | ||
}; | ||
|
||
export default config; |
Oops, something went wrong.