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

🧰 Frontend Infrastructure and Tooling 🛠️ #3

Merged
merged 22 commits into from
Apr 12, 2021
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Setup Jest + Playwright for E2E tests
codemonkey800 committed Apr 9, 2021
commit b53b4ed76c20333d5826465bfc492f8e8853899c
39 changes: 39 additions & 0 deletions client/jest/e2e.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const isHeadful =
process.env.HEADFUL === 'true' || process.env.HEADLESS === 'false';

const DEFAULT_LAUNCH_CONFIG = {
args: ['--ignore-certificate-errors', '--ignore-ssl-errors'],
headless: !isHeadful,
ignoreHTTPSErrors: true,
};

const DEFAULT_CONTEXT_CONFIG = {
acceptDownloads: true,
};

module.exports = {
rootDir: '..',
preset: 'jest-playwright-preset',
testMatch: ['<rootDir>/tests/**/*.test.ts'],

moduleNameMapper: {
'^@/tests/(.*)$': '<rootDir>/tests/$1',
},

setupFilesAfterEnv: [
'expect-playwright',
'<rootDir>/jest/playwright.setup.ts',
],

testEnvironmentOptions: {
'jest-playwright': {
browserContext: 'incognito',
contextOptions: DEFAULT_CONTEXT_CONFIG,
launchOptions: DEFAULT_LAUNCH_CONFIG,
},
},

transform: {
'\\.tsx?$': 'babel-jest',
},
};
2 changes: 2 additions & 0 deletions client/jest/playwright.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Increase max time to prevent test from browser shutting down too soon.
jest.setTimeout(2 * 60 * 1000);
3 changes: 3 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -7,6 +7,9 @@
"dev": "nodemon -x 'run-p dev:*' -w tailwind.config.js",
"dev:next": "next dev -p 8080",
"dev:tsm": "tsm -w -e default 'src/**/*.module.scss'",
"e2e": "jest -c jest/e2e.config.js",
"e2e:watch": "pnpm e2e -- --watch",
"e2e:update": "pnpm e2e -- --updateSnapshot",
"start": "next start -p 8080",
"test": "jest -c jest/test.config.js",
"test:watch": "pnpm jest -- --watch",
12 changes: 12 additions & 0 deletions client/tests/pages/home.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
describe('/ (Home page)', () => {
beforeAll(async () => {
await page.goto('http://localhost:8080');
});

it('should render hello world', async () => {
await expect(page).toHaveText(
'[data-napari-test=homeText]',
'Hello, World!',
);
});
});
4 changes: 4 additions & 0 deletions client/tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
// TODO Remove when overrides are addeded to `tsconfig.json`
"extends": "../tsconfig.jest.json"
}
2 changes: 1 addition & 1 deletion client/tsconfig.jest.json
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
"@/tests/*": ["./tests/*"]
},

"types": ["jest"]
"types": ["jest-playwright-preset", "expect-playwright", "jest"]
},
"include": ["*.d.ts", "**/*.ts", "**/*.tsx"]
}