@brightspace-ui/testing 1.19.0 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Testing utilities which are specifically designed and configured for Brightspace UI components and applications.
6
6
 
7
- > **Migrating from `@open-wc/testing` and/or `@brightspace-ui/visual-diff`?**
7
+ > **Migrating from `@open-wc/testing`/`@web/test-runner`?**
8
8
  > Refer to the [Migration Guide](docs/migration-guide.md) for help migrating a repo to `@brightspace-ui/testing`.
9
9
 
10
10
  Install from NPM:
@@ -479,6 +479,7 @@ Vdiff tests are written [just like other tests](#writing-tests), and the same ut
479
479
  Use the asynchronous `.to.be.golden()` Chai assertion to take a vdiff snapshot and [compare it against its golden](#generating-the-goldens).
480
480
 
481
481
  ```javascript
482
+ import './my-elem.js';
482
483
  import { fixture, html } from '@brightspace-ui/testing';
483
484
 
484
485
  describe('my-elem', () => {
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import commandLineArgs from 'command-line-args';
3
- import { execSync } from 'node:child_process';
4
3
  import process from 'node:process';
5
4
  import { runner } from '../src/server/cli/test-runner.js';
6
5
 
@@ -19,21 +18,6 @@ if (cli.subcommand === 'vdiff') {
19
18
  } else if (vdiff.subcommand === 'report') {
20
19
  const { report } = await import('../src/server/cli/vdiff/report.js');
21
20
  await report.start();
22
- } else if (vdiff.subcommand === 'migrate') {
23
- const { migrate } = await import('../src/server/cli/vdiff/migrate.js');
24
- await migrate.start(vdiff._unknown);
25
- } else if (vdiff.subcommand === 'migrate-local') {
26
-
27
- const { pattern = './**' } = commandLineArgs({ name: 'pattern', type: String, defaultOption: true }, { partial: true, argv: vdiff._unknown || [] });
28
-
29
- stdout.write('\nInstalling @brightspace-ui/visual-diff\n');
30
- execSync('npm install @brightspace-ui/visual-diff@14 --no-save');
31
- stdout.write(`\nRunning existing tests for pattern '${pattern}/*.visual-diff.js'\n`);
32
- execSync(`npx mocha '${pattern}/*.visual-diff.js' -t 10000 --golden`);
33
- stdout.write('\nTest run complete.\n');
34
-
35
- const { migrate } = await import('../src/server/cli/vdiff/migrate.js');
36
- await migrate.start(vdiff._unknown, true);
37
21
  } else {
38
22
  stdout.write(`\nfatal: unknown subcommand: ${vdiff.subcommand}\n`);
39
23
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@brightspace-ui/testing",
3
3
  "description": "Utilities for testing front-end components and applications",
4
4
  "type": "module",
5
- "version": "1.19.0",
5
+ "version": "1.20.0",
6
6
  "repository": "https://github.com/BrightspaceUI/testing.git",
7
7
  "scripts": {
8
8
  "lint": "npm run lint:eslint && npm run lint:style",
@@ -159,14 +159,6 @@ async function getTestRunnerOptions(argv = []) {
159
159
  {
160
160
  example: 'vdiff golden',
161
161
  desc: 'Generate new golden screenshots'
162
- },
163
- {
164
- example: 'vdiff migrate [directory]',
165
- desc: 'Migrate from @brightspace-ui/visual-diff. Restrict which goldens are migrated with a directory glob.'
166
- },
167
- {
168
- example: 'vdiff migrate-local [directory]',
169
- desc: 'Generate goldens with @brightspace-ui/visual-diff for local comparison while migrating tests. Restrict which goldens are generated with a directory glob.'
170
162
  }]
171
163
  }
172
164
  ]);
@@ -1,53 +0,0 @@
1
- #!/usr/bin/env node
2
- import { appendFile, mkdir, readFile, rename, rm } from 'node:fs/promises';
3
- import { join, normalize, parse } from 'node:path';
4
- import commandLineArgs from 'command-line-args';
5
- import { glob } from 'glob';
6
- import { PATHS } from '../../paths.js';
7
- import { stdout } from 'node:process';
8
-
9
- async function start(argv = [], local = false) {
10
- const { pattern = './**' } = commandLineArgs({ name: 'pattern', type: String, defaultOption: true }, { partial: true, argv });
11
- const oldSuffix = local ? 'screenshots/golden' : 'screenshots/ci/golden';
12
-
13
- stdout.write(`\nMigrating goldens for pattern '${pattern}/${oldSuffix}'\n`);
14
- const dirs = await glob(`${pattern}/${oldSuffix}`, { ignore: 'node_modules/**', posix: true });
15
- let fileCount = 0;
16
-
17
- const gitignore = await readFile('.gitignore', { encoding: 'UTF8' }).catch(() => '');
18
- if (!new RegExp(`${PATHS.VDIFF_ROOT}/(\n|$)`).test(gitignore)) {
19
- const newline = gitignore.endsWith('\n') ? '' : '\n';
20
- await appendFile('.gitignore', `${newline}${PATHS.VDIFF_ROOT}/\n`);
21
- }
22
-
23
- await Promise.all(dirs.map(async dir => {
24
- const files = await glob(`${dir}/*/*.png`, { posix: true });
25
-
26
- await Promise.all(files.map(async file => {
27
- fileCount += 1;
28
- const { base: name, dir } = parse(file);
29
- const dirName = parse(dir).name;
30
-
31
- const newName = name
32
- .replace(/^d2l-/, '')
33
- .replace(new RegExp(`^${dirName}-`), '');
34
-
35
- const newDir = local ?
36
- `${PATHS.VDIFF_ROOT}/${dir.replace(`${oldSuffix}/${dirName}`, `${dirName}/${PATHS.GOLDEN}/chromium`)}` :
37
- dir.replace(`${oldSuffix}/${dirName}`, `${PATHS.GOLDEN}/${dirName}/chromium`);
38
-
39
- await mkdir(newDir, { recursive: true });
40
- return rename(file, join(newDir, newName));
41
- }));
42
-
43
- if (!local) {
44
- return rm(normalize(join(dir, '..', '..')), { recursive: true });
45
- }
46
- }));
47
-
48
- stdout.write(`\nMigrated ${fileCount} ${fileCount === 1 ? 'golden' : 'goldens'} found in ${dirs.length} test ${dirs.length === 1 ? 'directory' : 'directories'}\n`);
49
- }
50
-
51
- export const migrate = {
52
- start
53
- };