@ngx-playwright/jest
Builder for running e2e tests in an angular application using jest and playwright with Angular CDK's component harnesses.
Set up
-
Install this package and
ts-jest
-
Depending on your usage, you may have to install
playwright
,playwright-chromium
,playwright-firefox
orplaywright-webkit
-
Create an
application/jest.e2e-config.js
e.g.module.exports = { ...require('ts-jest/presets').defaults, preset: '@ngx-playwright/jest', rootDir: '.', testMatch: ['<rootDir>/e2e/specs/*.spec.ts'], globals: { 'ts-jest': { tsconfig: '<rootDir>/e2e/tsconfig.json', }, }, };
-
Configure your e2e tests in the
angular.json
:"e2e": { "builder": "@ngx-playwright/jest:run", "options": { "devServerTarget": "application:serve", "config": "application/jest.e2e-config.js" } },
-
Configure typescript by creating a small file called
application/e2e/setup.d.ts
containingimport '@ngx-playwright/jest/global';
and configuring
application/e2e/tsconfig.json
:{ "compilerOptions": { // include any compiler options you want "types": ["jest"] }, "include": ["setup.d.ts", "specs/*.spec.ts"] }
This will make extra global variables available in your test, such as
browser
,browserContext
,page
, andharnessEnvironment
, as well as all regular jest globals.
Configuration
TODO
License
Licensed under the MIT license, see LICENSE.md
.