Skip to content

Commit

Permalink
feat(test): move from cypress to playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
roedoejet committed Oct 25, 2023
1 parent 7778d8f commit 2737b65
Show file tree
Hide file tree
Showing 23 changed files with 45,024 additions and 45,471 deletions.
9 changes: 8 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"files": ["*.ts"],
"parserOptions": {
"project": ["tsconfig.json", "cypress/tsconfig.json"],
"project": ["tsconfig.json"],
"createDefaultProgram": true
},
"extends": [
Expand All @@ -16,6 +16,13 @@
"rules": {
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/quotes": [
"off",
"single",
{
"allowTemplateLiterals": true
}
],
"@typescript-eslint/explicit-member-accessibility": [
"off",
{
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ jobs:
node-version: 18
- name: Install everything
run: npm install
- name: Cypress run
uses: cypress-io/github-action@v6
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx npm run-script e2e
- uses: actions/upload-artifact@v3
if: always()
with:
install: false
start: |
npm start
wait-on: "http://localhost:4200/assets/data/fr/v1/options.json"
wait-on-timeout: 180
command: npm run-script cypress:run
name: playwright-report
path: playwright-report/
retention-days: 30
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ projects/word-weaver/src/assets/trim.*
scripts/poeditor_api_token.txt
scripts/*.json
/.angular/cache
coverage
coverage
/test-results/
/playwright-report/
/playwright/.cache/
48 changes: 0 additions & 48 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,53 +152,6 @@
"projects/word-weaver/**/*.html"
]
}
},
"cypress-run": {
"builder": "@cypress/schematic:cypress",
"options": {
"devServerTarget": "word-weaver:serve",
"configFile": "projects/word-weaver/cypress.config.ts"
},
"configurations": {
"production": {
"devServerTarget": "word-weaver:serve:production"
}
}
},
"cypress-open": {
"builder": "@cypress/schematic:cypress",
"options": {
"watch": true,
"headless": false,
"configFile": "projects/word-weaver/cypress.config.ts"
}
},
"ct": {
"builder": "@cypress/schematic:cypress",
"options": {
"devServerTarget": "word-weaver:serve",
"watch": true,
"headless": false,
"testingType": "component"
},
"configurations": {
"development": {
"devServerTarget": "word-weaver:serve:development"
}
}
},
"e2e": {
"builder": "@cypress/schematic:cypress",
"options": {
"devServerTarget": "word-weaver:serve",
"watch": true,
"headless": false
},
"configurations": {
"development": {
"devServerTarget": "word-weaver:serve:development"
}
}
}
}
}
Expand All @@ -208,7 +161,6 @@
"analytics": false,
"schematicCollections": [
"@angular-eslint/schematics",
"@cypress/schematic",
"@schematics/angular"
]
}
Expand Down
34 changes: 34 additions & 0 deletions e2e-tests/coverage.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { test } from "@playwright/test";
import { attachCoverageReport } from "monocart-reporter";
const HOME = "localhost:4200";

test("Take V8 and Istanbul coverage report", async ({ page, browserName }) => {
if (browserName === "chromium") {
await Promise.all([
page.coverage.startJSCoverage({
resetOnNavigation: false,
}),
page.coverage.startCSSCoverage({
resetOnNavigation: false,
}),
]);

await page.goto(HOME);

// delay for mock code execution
await new Promise((resolve) => {
setTimeout(resolve, 500);
});

const [jsCoverage, cssCoverage] = await Promise.all([
page.coverage.stopJSCoverage(),
page.coverage.stopCSSCoverage(),
]);
await page.close();

const coverageList = [...jsCoverage, ...cssCoverage];

const v8 = await attachCoverageReport(coverageList, test.info(), {});
console.log(v8.summary);
}
});
26 changes: 26 additions & 0 deletions e2e-tests/e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { test, expect } from "@playwright/test";
const HOME = "localhost:4200";

test("has title", async ({ page }) => {
await page.goto(HOME);

// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/WordWeaver/);
});

test("navigate to tableviewer", async ({ page }) => {
await page.goto(HOME + "/tableviewer");

// Expects page to have a heading with the name of Installation.
await expect(page.url()).toContain("tableviewer");
});

test("get started link", async ({ page }) => {
await page.goto(HOME);

// Click the get started link.
await page.getByTestId("start").click();

// Expects page to have a heading with the name of Installation.
await expect(page.url()).toContain("stepper");
});
Loading

0 comments on commit 2737b65

Please sign in to comment.