Replace Saucelabs with Playwright

Also reorganized npm scripts.
This commit is contained in:
Jakob Linskeseder
2021-12-22 21:05:06 +01:00
committed by Jay Linski
parent ef0fc290b9
commit 9ed9418488
18 changed files with 3451 additions and 443 deletions
+5
View File
@@ -0,0 +1,5 @@
module.exports = {
parserOptions: {
ecmaVersion: 2020
}
};
+14
View File
@@ -0,0 +1,14 @@
# Browser Tests with Playwright
These tests execute Mocha tests from the `spec`-folder in multiple browsers.
## Using Docker
Execute the following commands in the project root:
```bash
npm install
npx grunt prepare
docker pull mcr.microsoft.com/playwright:focal
docker run -it --rm --volume $(pwd):/srv/app --workdir /srv/app --ipc=host mcr.microsoft.com/playwright:focal npm run test:browser
```
+27
View File
@@ -0,0 +1,27 @@
const { devices } = require('@playwright/test');
/** @type {import('@playwright/test').PlaywrightTestConfig} */
const config = {
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] }
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] }
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] }
}
],
reporter: 'list',
webServer: {
command: 'npm run test:serve',
port: 3000,
reuseExistingServer: false
}
};
module.exports = config;
+33
View File
@@ -0,0 +1,33 @@
const { test, expect } = require('@playwright/test');
async function waitForMochaAndAssertResult(page) {
await page.waitForFunction(() => window.mochaResults); // eslint-disable-line no-undef
const mochaResults = await page.evaluate('window.mochaResults');
expect(mochaResults.failures).toBe(0);
}
test('Spec handlebars.js', async ({ page, baseURL }) => {
await page.goto(`${baseURL}/spec/?headless=true`);
await waitForMochaAndAssertResult(page);
});
test('Spec handlebars.amd.js (AMD)', async ({ page, baseURL }) => {
await page.goto(`${baseURL}/spec/amd.html?headless=true`);
await waitForMochaAndAssertResult(page);
});
test('Spec handlebars.runtime.amd.js (AMD)', async ({ page, baseURL }) => {
await page.goto(`${baseURL}/spec/amd-runtime.html?headless=true`);
await waitForMochaAndAssertResult(page);
});
test('Spec handlebars.js (UMD)', async ({ page, baseURL }) => {
await page.goto(`${baseURL}/spec/umd.html?headless=true`);
await waitForMochaAndAssertResult(page);
});
test('Spec handlebars.runtime.js (UMD)', async ({ page, baseURL }) => {
await page.goto(`${baseURL}/spec/umd-runtime.html?headless=true`);
await waitForMochaAndAssertResult(page);
});