Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: install playwright dependencies ourselves #126

Merged
merged 2 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() {
await runner.install();
dlockhart marked this conversation as resolved.
Show resolved Hide resolved
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' });
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I played around with the async version of this and wrapped it in a Promise, but marshalling the stdout/err around seemed way more complicated than it was worth. Open to other suggestions though.

}

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);
});

});