test: wire test commands to jest (#3014)
This commit is contained in:
parent
8904f401c2
commit
9d9801192e
42
.github/workflows/tests.yml
vendored
42
.github/workflows/tests.yml
vendored
|
|
@ -37,14 +37,12 @@ jobs:
|
||||||
# XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR
|
# XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR
|
||||||
# Wrap `npm run` in a subshell to redirect STDERR to file.
|
# Wrap `npm run` in a subshell to redirect STDERR to file.
|
||||||
# Enable core dumps in the subshell.
|
# Enable core dumps in the subshell.
|
||||||
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run test 2>./testrun.log"
|
|
||||||
env:
|
|
||||||
BROWSER: ${{ matrix.browser }}
|
|
||||||
DEBUG: "*,-pw:wrapped*"
|
|
||||||
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run jest -- --testTimeout=30000"
|
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run jest -- --testTimeout=30000"
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
env:
|
env:
|
||||||
BROWSER: ${{ matrix.browser }}
|
BROWSER: ${{ matrix.browser }}
|
||||||
|
DEBUG: "*,-pw:wrapped*"
|
||||||
|
DEBUG_FILE: "testrun.log"
|
||||||
- uses: actions/upload-artifact@v1
|
- uses: actions/upload-artifact@v1
|
||||||
if: failure()
|
if: failure()
|
||||||
with:
|
with:
|
||||||
|
|
@ -76,14 +74,11 @@ jobs:
|
||||||
- uses: microsoft/playwright-github-action@v1
|
- uses: microsoft/playwright-github-action@v1
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
- run: npm run test 2>./${{ matrix.browser }}-mac-testrun.log
|
- run: npm run jest -- --testTimeout=30000
|
||||||
env:
|
env:
|
||||||
BROWSER: ${{ matrix.browser }}
|
BROWSER: ${{ matrix.browser }}
|
||||||
DEBUG: "*,-pw:wrapped*"
|
DEBUG: "*,-pw:wrapped*"
|
||||||
- run: npm run jest -- --testTimeout=30000
|
DEBUG_FILE: "testrun.log"
|
||||||
if: ${{ always() }}
|
|
||||||
env:
|
|
||||||
BROWSER: ${{ matrix.browser }}
|
|
||||||
- uses: actions/upload-artifact@v1
|
- uses: actions/upload-artifact@v1
|
||||||
if: failure()
|
if: failure()
|
||||||
with:
|
with:
|
||||||
|
|
@ -93,7 +88,7 @@ jobs:
|
||||||
if: failure()
|
if: failure()
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.browser }}-mac-testrun.log
|
name: ${{ matrix.browser }}-mac-testrun.log
|
||||||
path: ${{ matrix.browser }}-mac-testrun.log
|
path: testrun.log
|
||||||
|
|
||||||
test_win:
|
test_win:
|
||||||
name: "Windows"
|
name: "Windows"
|
||||||
|
|
@ -110,16 +105,12 @@ jobs:
|
||||||
- uses: microsoft/playwright-github-action@v1
|
- uses: microsoft/playwright-github-action@v1
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
- run: npm run test 2>./${{ matrix.browser }}-win-testrun.log
|
- run: npm run jest -- --testTimeout=30000
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
BROWSER: ${{ matrix.browser }}
|
BROWSER: ${{ matrix.browser }}
|
||||||
DEBUG: "*,-pw:wrapped*"
|
DEBUG: "*,-pw:wrapped*"
|
||||||
- run: npm run jest -- --testTimeout=30000
|
DEBUG_FILE: "testrun.log"
|
||||||
if: ${{ always() }}
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
BROWSER: ${{ matrix.browser }}
|
|
||||||
- uses: actions/upload-artifact@v1
|
- uses: actions/upload-artifact@v1
|
||||||
if: failure()
|
if: failure()
|
||||||
with:
|
with:
|
||||||
|
|
@ -129,7 +120,7 @@ jobs:
|
||||||
if: failure()
|
if: failure()
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.browser }}-win-testrun.log
|
name: ${{ matrix.browser }}-win-testrun.log
|
||||||
path: ${{ matrix.browser }}-win-testrun.log
|
path: testrun.log
|
||||||
|
|
||||||
test-package-installations:
|
test-package-installations:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
@ -166,30 +157,29 @@ jobs:
|
||||||
# XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR
|
# XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR
|
||||||
# Wrap `npm run` in a subshell to redirect STDERR to file.
|
# Wrap `npm run` in a subshell to redirect STDERR to file.
|
||||||
# Enable core dumps in the subshell.
|
# Enable core dumps in the subshell.
|
||||||
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run test -- --line-break=100 2>./headful-linux-testrun.log"
|
|
||||||
env:
|
|
||||||
DEBUG: "*"
|
|
||||||
HEADLESS: "false"
|
|
||||||
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run jest -- --testTimeout=30000"
|
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run jest -- --testTimeout=30000"
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
env:
|
env:
|
||||||
BROWSER: "chromium"
|
BROWSER: "chromium"
|
||||||
HEADLESS: "false"
|
HEADLESS: "false"
|
||||||
|
DEBUG_FILE: "testrun.log"
|
||||||
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run jest -- --testTimeout=30000"
|
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run jest -- --testTimeout=30000"
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
env:
|
env:
|
||||||
BROWSER: "firefox"
|
BROWSER: "firefox"
|
||||||
HEADLESS: "false"
|
HEADLESS: "false"
|
||||||
|
DEBUG_FILE: "testrun.log"
|
||||||
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run jest -- --testTimeout=30000"
|
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run jest -- --testTimeout=30000"
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
env:
|
env:
|
||||||
BROWSER: "webkit"
|
BROWSER: "webkit"
|
||||||
HEADLESS: "false"
|
HEADLESS: "false"
|
||||||
|
DEBUG_FILE: "testrun.log"
|
||||||
- uses: actions/upload-artifact@v1
|
- uses: actions/upload-artifact@v1
|
||||||
if: failure()
|
if: failure()
|
||||||
with:
|
with:
|
||||||
name: headful-linux-testrun.log
|
name: headful-linux-testrun.log
|
||||||
path: headful-linux-testrun.log
|
path: testrun.log
|
||||||
- uses: actions/upload-artifact@v1
|
- uses: actions/upload-artifact@v1
|
||||||
if: failure()
|
if: failure()
|
||||||
with:
|
with:
|
||||||
|
|
@ -218,15 +208,11 @@ jobs:
|
||||||
# XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR
|
# XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR
|
||||||
# Wrap `npm run` in a subshell to redirect STDERR to file.
|
# Wrap `npm run` in a subshell to redirect STDERR to file.
|
||||||
# Enable core dumps in the subshell.
|
# Enable core dumps in the subshell.
|
||||||
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run test 2>./testrun.log"
|
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run jest -- --testTimeout=30000"
|
||||||
env:
|
env:
|
||||||
BROWSER: ${{ matrix.browser }}
|
BROWSER: ${{ matrix.browser }}
|
||||||
DEBUG: "*,-pw:wrapped*"
|
DEBUG: "*,-pw:wrapped*"
|
||||||
PWCHANNEL: ${{ matrix.transport }}
|
DEBUG_FILE: "testrun.log"
|
||||||
- run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && npm run jest -- --testTimeout=30000"
|
|
||||||
if: ${{ always() }}
|
|
||||||
env:
|
|
||||||
BROWSER: ${{ matrix.browser }}
|
|
||||||
PWCHANNEL: ${{ matrix.transport }}
|
PWCHANNEL: ${{ matrix.transport }}
|
||||||
- uses: actions/upload-artifact@v1
|
- uses: actions/upload-artifact@v1
|
||||||
if: failure()
|
if: failure()
|
||||||
|
|
|
||||||
12
package.json
12
package.json
|
|
@ -9,14 +9,10 @@
|
||||||
"node": ">=10.15.0"
|
"node": ">=10.15.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ctest": "cross-env BROWSER=chromium node --unhandled-rejections=strict test/test.js",
|
"ctest": "cross-env BROWSER=chromium npm run jest",
|
||||||
"ftest": "cross-env BROWSER=firefox node --unhandled-rejections=strict test/test.js",
|
"ftest": "cross-env BROWSER=firefox npm run jest",
|
||||||
"wtest": "cross-env BROWSER=webkit node --unhandled-rejections=strict test/test.js",
|
"wtest": "cross-env BROWSER=webkit npm run jest",
|
||||||
"test": "cross-env node --unhandled-rejections=strict test/test.js",
|
"test": "npm run ctest && npm run ftest && npm run wtest",
|
||||||
"ccoverage": "cross-env COVERAGE=true BROWSER=chromium node --unhandled-rejections=strict test/test.js",
|
|
||||||
"fcoverage": "cross-env COVERAGE=true BROWSER=firefox node --unhandled-rejections=strict test/test.js",
|
|
||||||
"wcoverage": "cross-env COVERAGE=true BROWSER=webkit node --unhandled-rejections=strict test/test.js",
|
|
||||||
"coverage": "cross-env COVERAGE=true node --unhandled-rejections=strict test/test.js",
|
|
||||||
"eslint": "[ \"$CI\" = true ] && eslint --quiet -f codeframe --ext js,ts ./src || eslint --ext js,ts ./src",
|
"eslint": "[ \"$CI\" = true ] && eslint --quiet -f codeframe --ext js,ts ./src || eslint --ext js,ts ./src",
|
||||||
"tsc": "tsc -p .",
|
"tsc": "tsc -p .",
|
||||||
"tsc-installer": "tsc -p ./src/install/tsconfig.json",
|
"tsc-installer": "tsc -p ./src/install/tsconfig.json",
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as debug from 'debug';
|
import * as debug from 'debug';
|
||||||
|
import * as fs from 'fs';
|
||||||
import { helper } from './helper';
|
import { helper } from './helper';
|
||||||
import { LoggerSink, LoggerSeverity } from './loggerSink';
|
import { LoggerSink, LoggerSeverity } from './loggerSink';
|
||||||
|
|
||||||
|
|
@ -142,6 +143,19 @@ const colorMap = new Map<string, number>([
|
||||||
|
|
||||||
export class DebugLoggerSink {
|
export class DebugLoggerSink {
|
||||||
private _debuggers = new Map<string, debug.IDebugger>();
|
private _debuggers = new Map<string, debug.IDebugger>();
|
||||||
|
constructor() {
|
||||||
|
if (process.env.DEBUG_FILE) {
|
||||||
|
const ansiRegex = new RegExp([
|
||||||
|
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
|
||||||
|
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
|
||||||
|
].join('|'), 'g');
|
||||||
|
const stream = fs.createWriteStream(process.env.DEBUG_FILE);
|
||||||
|
(debug as any).log = (data: string) => {
|
||||||
|
stream.write(data.replace(ansiRegex, ''));
|
||||||
|
stream.write('\n');
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
isEnabled(name: string, severity: LoggerSeverity): boolean {
|
isEnabled(name: string, severity: LoggerSeverity): boolean {
|
||||||
return debug.enabled(`pw:${name}`);
|
return debug.enabled(`pw:${name}`);
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const config = require('../test.config');
|
|
||||||
const utils = require('../utils');
|
|
||||||
|
|
||||||
const electronName = process.platform === 'win32' ? 'electron.cmd' : 'electron';
|
const electronName = process.platform === 'win32' ? 'electron.cmd' : 'electron';
|
||||||
|
|
||||||
|
const { CHROMIUM } = testOptions;
|
||||||
|
|
||||||
registerFixture('application', async ({playwright}, test) => {
|
registerFixture('application', async ({playwright}, test) => {
|
||||||
const electronPath = path.join(__dirname, '..', '..', 'node_modules', '.bin', electronName);
|
const electronPath = path.join(__dirname, '..', '..', 'node_modules', '.bin', electronName);
|
||||||
const application = await playwright.electron.launch(electronPath, {
|
const application = await playwright.electron.launch(electronPath, {
|
||||||
|
|
@ -41,7 +40,7 @@ registerFixture('window', async ({application}, test) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Electron', function() {
|
describe.skip(!CHROMIUM)('Electron', function() {
|
||||||
it('should script application', async ({ application }) => {
|
it('should script application', async ({ application }) => {
|
||||||
const appPath = await application.evaluate(async ({ app }) => app.getAppPath());
|
const appPath = await application.evaluate(async ({ app }) => app.getAppPath());
|
||||||
expect(appPath).toContain('electron');
|
expect(appPath).toContain('electron');
|
||||||
|
|
@ -124,7 +123,7 @@ describe('Electron', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Electron per window', function() {
|
describe.skip(!CHROMIUM)('Electron per window', function() {
|
||||||
it('should click the button', async({window, server}) => {
|
it('should click the button', async({window, server}) => {
|
||||||
await window.goto(server.PREFIX + '/input/button.html');
|
await window.goto(server.PREFIX + '/input/button.html');
|
||||||
await window.click('button');
|
await window.click('button');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue