Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ Use the `d2l-test-runner` binary to execute a set of tests and report their resu
| timeout | `Number` | `2000` | Test timeout threshold in ms |
| filter | `String` | | Filter test files by replacing wildcards with this glob |
| grep | `String` | | Only run tests matching this string or regexp |
| files | `String` | `'./test/**/*.<group>.js'` | Test files to run. Path or glob. |
| files | `String` | `'./**/test/**/*.<group>.js'` | Test files to run. Path or glob. |
| config | `String` | `'./d2l-test-runner.config.js'` | Location of config file |
| watch | `Boolean` | `false` | Reload tests on file changes. Allows debugging in all browsers. |
| open | `Boolean` | `false` | Open the browser in headed mode |
Expand Down Expand Up @@ -461,9 +461,9 @@ export default {

Tests are organized into groups, which can be configured and run together.

The group name appears in the default `files` pattern (`'./test/**/*.<group>.js'`), making it typical for test files to have the group name as part of their extension. For example, the default group is `'test'` so all test files named `*.test.js` will belong to it by default. Similarly, the `vdiff` group contains files named `*.vdiff.js`.
The group name appears in the default `files` pattern (`'./**/test/**/*.<group>.js'`), making it typical for test files to have the group name as part of their extension. For example, the default group is `'test'` so all test files named `*.test.js` will belong to it by default. Similarly, the `vdiff` group contains files named `*.vdiff.js`.

To run tests which match the pattern `'./test/**/*.mygroup.js'`:
To run tests which match the pattern `'./**/test/**/*.mygroup.js'`:
```bash
d2l-test-runner --group mygroup
```
Expand All @@ -488,9 +488,9 @@ While writing or debugging tests, it can be desirable to focus the runner on a s

Use the `filter` option to filter by file name. It replaces any wildcards in the file name portion of the `files` pattern with the provided [glob](https://en.wikipedia.org/wiki/Glob_(programming)).

For example, with the `'test'` group and default pattern `'./test/**/*.<group>.js'`, passing `d2l-test-runner --filter foo` will run tests which match `'./test/**/foo.test.js'`.
For example, with the `'test'` group and default pattern `'./**/test/**/*.<group>.js'`, passing `d2l-test-runner --filter foo` will run tests which match `'./**/test/**/foo.test.js'`.

Wildcards can still be used but need to be escaped. So `d2l-test-runner --filter foo\*` will run tests which match `'./test/**/foo*.test.js'`.
Wildcards can still be used but need to be escaped. So `d2l-test-runner --filter foo\*` will run tests which match `'./**/test/**/foo*.test.js'`.

### By Test Name

Expand Down
4 changes: 2 additions & 2 deletions docs/migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ By default, `d2l-test-runner` will:

* Run in Chrome, Firefox and Safari (except `vdiff` just runs in Chrome)
* Enable the `--node-resolve` flag
* Look for tests in `./test/**/*.test.js` (using the `test` group)
* Look for tests in `./**/test/**/*.test.js` (using the `test` group)
* Suppress `ResizeObserver` errors (a common reason repos use a config file)

Due to these new defaults, if the repo is using a `web-test-runner.config.js`, it may no longer be necessary and could be removed. If the config file is necessary, rename it to `d2l-test-runner.config.js`.
Expand All @@ -165,7 +165,7 @@ Before

```yml
"scripts": {
"test:unit": "web-test-runner --files \"./test/**/*.test.js\" --node-resolve"
"test:unit": "web-test-runner --files \"./**/test/**/*.test.js\" --node-resolve"
}
```

Expand Down
2 changes: 1 addition & 1 deletion src/server/cli/test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function getTestRunnerOptions(argv = []) {
name: 'files',
type: String,
multiple: true,
description: 'Test files to run. Path or glob.\n[Default: ./test/**/*.<group>.js]',
description: 'Test files to run. Path or glob.\n[Default: ./**/test/**/*.<group>.js]',
order: 8
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/server/wtr-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const defaultReporterGrep = () => {
};
};

const DEFAULT_PATTERN = type => `./test/**/*.${type}.js`;
const DEFAULT_PATTERN = type => `./**/test/**/*.${type}.js`;
Comment thread
dlockhart marked this conversation as resolved.
const DEFAULT_TEST_REPORTING = !!env['CI'];
const BROWSER_MAP = {
chrome: 'chromium',
Expand Down
2 changes: 1 addition & 1 deletion test/server/cli/test-runner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('runner.getOptions()', () => {
expect(opts.config.groups).to.be.an('array').with.length(1);
expect(opts.config.groups[0]).to.deep.include({
name: 'test',
files: [ './test/**/*.test.js', '!**/node_modules/**/*' ]
files: [ './**/test/**/*.test.js', '!**/node_modules/**/*' ]
});
});

Expand Down
10 changes: 5 additions & 5 deletions test/server/wtr-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('WTRConfig', () => {
const group = config.groups[0];
expect(config.groups).to.be.an('array').that.has.length(1);
expect(group.name).to.equal('implicit-group');
expect(group.files).to.include.members(['./test/**/*.implicit-group.js']);
expect(group.files).to.include.members(['./**/test/**/*.implicit-group.js']);
expect(group.browsers).to.be.an('array').that.has.length(3);
});

Expand All @@ -44,7 +44,7 @@ describe('WTRConfig', () => {
const group = config.groups[0];
expect(config.groups).to.be.an('array').that.has.length(1);
expect(group.name).to.equal('a-group');
expect(group.files).to.include.members(['./test/**/*.a-group.js']);
expect(group.files).to.include.members(['./**/test/**/*.a-group.js']);
});

it('should enable nodeResolve to default', () => {
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('WTRConfig', () => {
});

it('should set a common default files pattern', () => {
expect(config.groups[0].files).to.deep.equal([ './test/**/*.test.js', '!**/node_modules/**/*' ]);
expect(config.groups[0].files).to.deep.equal([ './**/test/**/*.test.js', '!**/node_modules/**/*' ]);
});

it('should run a given pattern function to set files', () => {
Expand Down Expand Up @@ -149,10 +149,10 @@ describe('WTRConfig', () => {

it('should filter test files using --filter values', () => {
const wtrConfig = new WTRConfig({ filter: ['subset', 'subset*'] });
const config = wtrConfig.create({ pattern: type => `./test/**/*/*.${type}.*` });
const config = wtrConfig.create({ pattern: type => `./**/test/**/*/*.${type}.*` });
expect(config.files).to.be.undefined;
expect(config.groups[0].files).to.have.length(3);
expect(config.groups[0].files).to.have.members(['./test/**/*/+(subset.test.*|*.test.subset)', './test/**/*/+(subset*.test.*|*.test.subset*)', '!**/node_modules/**/*']);
expect(config.groups[0].files).to.have.members(['./**/test/**/*/+(subset.test.*|*.test.subset)', './**/test/**/*/+(subset*.test.*|*.test.subset*)', '!**/node_modules/**/*']);
});

it('should never filter excluded files', () => {
Expand Down