Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package e2e testing #402

Merged
merged 9 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ build
# misc
.DS_Store
*.pem

# e2e storage state
packages/e2e-testing/__tests__/utils/storageState.json
3 changes: 0 additions & 3 deletions packages/create-codes/templates/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"build": "tsc && vite build",
"lint": "eslint . --ext .js,jsx,.ts,.tsx",
"preview": "vite preview",
"e2e": "playwright test",
"test": "jest",
"test:coverage": "jest --coverage",
"type": "tsc --noEmit"
Expand All @@ -22,11 +21,9 @@
"@babel/preset-env": "7.20.2",
"@babel/preset-react": "7.18.6",
"@babel/preset-typescript": "7.18.6",
"@playwright/test": "1.29.2",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "13.4.0",
"@testing-library/user-event": "14.4.3",
"@types/node": "18.11.18",
"@types/react": "18.0.27",
"@types/react-dom": "18.0.10",
"@typescript-eslint/eslint-plugin": "5.48.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const globalSetup = async (_config: FullConfig) => {
// Save signed-in state to 'storageState.json'.
await page
.context()
.storageState({ path: "./tests/e2e/utils/storageState.json" });
.storageState({ path: "./__tests__/utils/storageState.json" });
await browser.close();
};

Expand Down
17 changes: 17 additions & 0 deletions packages/e2e-testing/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "e2e-testing",
"private": true,
"scripts": {
"e2e:dev": "playwright test"
},
"dependencies": {
"@playwright/test": "1.29.2"
},
"devDependencies": {
"start-server-and-test": "1.15.2",
"reactjs-boilerplate": "workspace:*",
"tsconfig": "workspace:*",
"typescript": "4.9.4",
"@types/node": "18.11.18"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,22 @@ import { type PlaywrightTestConfig, devices } from "@playwright/test";

const config: PlaywrightTestConfig = {
forbidOnly: !!process.env.CI,
testDir: "./tests/e2e",
webServer: {
command: "yarn dev",
port: 3000,
},
testDir: "__tests__",
retries: process.env.CI ? 2 : 0,
globalSetup: require.resolve("./tests/e2e/utils/global-setup"),
globalSetup: require.resolve("./__tests__/utils/global-setup"),
use: {
headless: !!process.env.CI,
baseURL: "http://localhost:3000/",
// Tell all tests to load signed-in state from 'storageState.json'.
storageState: "./tests/e2e/utils/storageState.json",
storageState: "./__tests__/utils/storageState.json",
trace: "on-first-retry",
},
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
name: "react",
use: {
baseURL: "http://localhost:3000",
...devices["Desktop Chrome"],
},
},
],
};
Expand Down
7 changes: 7 additions & 0 deletions packages/e2e-testing/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "tsconfig/library.json",
"compilerOptions": {
"rootDir": "."
},
"include": ["playwright.config.ts", "__tests__"]
}
Loading