1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-09 11:29:58 +00:00
TiddlyWiki5/editions/test/playwright.spec.js
Maurycy Zarzycki 4b56cb4298
Add support for running in-browser tests via playwright in GitHub CLI (#7820)
* Add support for running in-browser tests via playwright in GitHub CLI

* `ci.yml` was updated to store the report so that it can be inspected on failure
* `ci-test.sh` was added as an expansion to `test.sh` which installs and runs playwright
* `playwright.spec.js` does the actual verification of opening the test TW edition in browser, waiting for the tests to finish and then verifying it has indeed passed
* `playwright.config.js` Playwrifht configuration

* Add support for running in-browser tests via playwright in GitHub CLI

* `ci.yml` was updated to store the report so that it can be inspected on failure
* `ci-test.sh` was added as an expansion to `test.sh` which installs and runs playwright
* `playwright.spec.js` does the actual verification of opening the test TW edition in browser, waiting for the tests to finish and then verifying it has indeed passed
* `playwright.config.js` Playwrifht configuration

* Fix file permissions for `ci-test.sh`

* Increased node version for github actions to support playwright

* Add installation of the required @playwright/test library during CI test execution
2023-10-29 09:05:24 +00:00

26 lines
1.1 KiB
JavaScript

const { test, expect } = require('@playwright/test');
const {resolve} = require('path');
const indexPath = resolve(__dirname, 'output', 'test.html');
const crossPlatformIndexPath = indexPath.replace(/^\/+/, '');
test('get started link', async ({ page }) => {
// The tests can take a while to run
const timeout = 1000 * 30;
test.setTimeout(timeout);
// Load the generated test TW html
await page.goto(`file:///${crossPlatformIndexPath}`);
// Sanity check
await expect(page.locator('.tc-site-title'), "Expected correct page title to verify the test page was loaded").toHaveText('TiddlyWiki5');
// Wait for jasmine results bar to appear
await expect(page.locator('.jasmine-overall-result'), "Expected jasmine test results bar to be present").toBeVisible({timeout});
// Assert the tests have passed
await expect(page.locator('.jasmine-overall-result.jasmine-failed'), "Expected jasmine tests to not have failed").not.toBeVisible();
await expect(page.locator('.jasmine-overall-result.jasmine-passed'), "Expected jasmine tests to have passed").toBeVisible();
});