@brightspace-ui/testing 1.7.1 → 1.8.1

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/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.7.1",
5
+ "version": "1.8.1",
6
6
  "repository": "https://github.com/BrightspaceUI/testing.git",
7
7
  "scripts": {
8
8
  "lint": "eslint . --ext .js",
@@ -133,7 +133,7 @@ async function getTestRunnerOptions(argv = []) {
133
133
  },
134
134
  {
135
135
  header: 'Usage',
136
- content: 'd2l-test-runner [options]\nd2l-test-runner <command> [options]\n',
136
+ content: 'd2l-test-runner [options]\nd2l-test-runner <group> [options]\nd2l-test-runner <command> [options]\n',
137
137
  },
138
138
  {
139
139
  header: 'Options',
@@ -54,7 +54,7 @@ export class WTRConfig {
54
54
  }
55
55
 
56
56
  get #pattern() {
57
- const files = this.#cliArgs.files || [ this.pattern(this.#cliArgs.group) ];
57
+ const files = [ this.#cliArgs.files || this.pattern(this.#cliArgs.group), '!**/node_modules/**/*' ].flat();
58
58
 
59
59
  if (this.#cliArgs.filter) {
60
60
  return this.#filterFiles(files);
@@ -126,16 +126,20 @@ export class WTRConfig {
126
126
  #filterFiles(files) {
127
127
  return this.#cliArgs.filter.map(filterStr => {
128
128
  // replace everything after the last forward slash
129
- return files.map(f => f.replace(/[^/]*$/, fileGlob => {
130
- // create a new glob for each wildcard
131
- const fileGlobs = Array.from(fileGlob.matchAll(/(?<!\*)\*(?!\*)/g)).map(({ index }) => {
132
- const arr = fileGlob.split('');
133
- arr.splice(index, 1, filterStr);
134
- return arr.join('');
135
- });
136
- return `+(${fileGlobs.join('|') || fileGlob})`;
137
- }));
138
- }).flat();
129
+ return files
130
+ .filter(f => !f.startsWith('!')) // don't filter exclusions
131
+ .map(f => f.replace(/[^/]*$/, fileGlob => {
132
+ // create a new glob for each wildcard
133
+ const fileGlobs = Array.from(fileGlob.matchAll(/(?<!\*)\*(?!\*)/g)).map(({ index }) => {
134
+ const arr = fileGlob.split('');
135
+ arr.splice(index, 1, filterStr);
136
+ return arr.join('');
137
+ });
138
+ return `+(${fileGlobs.join('|') || fileGlob})`;
139
+ }));
140
+ })
141
+ .flat()
142
+ .concat(files.filter(f => f.startsWith('!')));
139
143
  }
140
144
 
141
145
  #getMochaConfig(group, slowConfig, timeoutConfig) {
@@ -174,10 +178,6 @@ export class WTRConfig {
174
178
  const { files, filter, golden, grep, group, open, watch } = this.#cliArgs;
175
179
  const passthroughGroupNames = passthroughConfig.groups?.map(g => g.name) ?? [];
176
180
 
177
- if (!['test', 'vdiff', ...passthroughGroupNames].includes(group)) {
178
- return {}; // allow wtr to error
179
- }
180
-
181
181
  delete passthroughConfig.browsers;
182
182
 
183
183
  if (typeof pattern !== 'function') throw new TypeError('pattern must be a function');
@@ -189,6 +189,15 @@ export class WTRConfig {
189
189
  ...passthroughConfig
190
190
  };
191
191
 
192
+ if (!['test', 'vdiff', ...passthroughGroupNames].includes(group)) {
193
+ config.groups.push({ name: group, files: this.#pattern });
194
+ } else {
195
+ const groupConfig = config.groups.find(g => g.name === group);
196
+ if (groupConfig) {
197
+ groupConfig.files = this.#pattern;
198
+ }
199
+ }
200
+
192
201
  if (filter) {
193
202
  config.groups.forEach(group => {
194
203
  group.files = this.#filterFiles([ group.files ].flat());