Skip to content

Commit

Permalink
feat: install playwright dependencies ourselves (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlockhart authored Aug 10, 2023
1 parent 76ab715 commit 34ef730
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ jobs:
node-version-file: .nvmrc
cache: 'npm'
- name: Install dependencies
run: |
npm ci
npx playwright install-deps
run: npm ci
- name: Lint (JavaScript)
run: npm run lint
- name: Unit Tests (Browser)
Expand Down
1 change: 1 addition & 0 deletions bin/d2l-test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if (cli.subcommand === 'vdiff') {
}

async function runTests() {
runner.install();
const options = await runner.getOptions(argv);
await runner.start(options);
}
6 changes: 6 additions & 0 deletions src/server/cli/test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ConfigLoaderError, readConfig } from '@web/config-loader';
import { DEFAULT_VDIFF_SLOW, WTRConfig } from '../wtr-config.js';
import commandLineArgs from 'command-line-args';
import commandLineUsage from 'command-line-usage';
import { execSync } from 'node:child_process';
import process from 'node:process';
import { startTestRunner } from '@web/test-runner';

Expand Down Expand Up @@ -196,7 +197,12 @@ async function getTestRunnerOptions(argv = []) {
};
}

function installDeps() {
execSync('npx playwright install-deps', { stdio: 'pipe' });
}

export const runner = {
getOptions: getTestRunnerOptions,
install: installDeps,
start: startTestRunner
};
8 changes: 8 additions & 0 deletions test/bin/d2l-test-runner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ describe('d2l-test-runner', () => {
const opts = { my: 'options' };
const optionsStub = stub(runner, 'getOptions').returns(opts);
const startStub = stub(runner, 'start');
const installStub = stub(runner, 'install');
await run();

assert.calledOnceWithExactly(optionsStub, argv);
assert.calledOnceWithExactly(startStub, opts);
assert.calledOnce(installStub);

restore();
});
Expand All @@ -33,18 +35,21 @@ describe('d2l-test-runner', () => {
const reportStub = stub(report, 'start');
const optionsStub = stub(runner, 'getOptions');
const startStub = stub(runner, 'start');
const installStub = stub(runner, 'install');

argv.splice(0, argv.length, 'fake-node', 'fake-test-runner', 'vdiff', 'report');
await run();

assert.calledOnce(reportStub);
assert.notCalled(optionsStub);
assert.notCalled(startStub);
assert.notCalled(installStub);
});

it('generates goldens', async() => {
const optionsStub = stub(runner, 'getOptions');
const startStub = stub(runner, 'start');
const installStub = stub(runner, 'install');
const stdoutStub = stub(stdout, 'write');

argv.splice(0, argv.length, 'fake-node', 'fake-test-runner', 'vdiff', 'golden');
Expand All @@ -53,20 +58,23 @@ describe('d2l-test-runner', () => {
expect(argv).to.deep.equal(['fake-node', 'fake-test-runner', 'vdiff', '--golden']);
assert.calledOnceWithExactly(optionsStub, argv);
assert.calledOnce(startStub);
assert.calledOnce(installStub);
assert.calledOnceWithExactly(stdoutStub, '\nGenerating vdiff goldens...\n');
});

it('starts migration', async() => {
const migrateStub = stub(migrate, 'start');
const optionsStub = stub(runner, 'getOptions');
const startStub = stub(runner, 'start');
const installStub = stub(runner, 'install');

argv.splice(0, argv.length, 'fake-node', 'fake-test-runner', 'vdiff', 'migrate', './test/**/dir');
await run();

assert.calledOnceWithExactly(migrateStub, ['./test/**/dir']);
assert.notCalled(optionsStub);
assert.notCalled(startStub);
assert.notCalled(installStub);
});

});

0 comments on commit 34ef730

Please sign in to comment.