test-inventory 0.9.0 → 0.9.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/CHANGELOG.md +100 -0
- package/dist/config-runs.d.ts +3 -3
- package/dist/config-runs.js +64 -32
- package/dist/files.d.ts +3 -2
- package/dist/files.js +52 -9
- package/dist/frameworks/bun.d.ts +2 -0
- package/dist/frameworks/bun.js +10 -2
- package/dist/frameworks/jasmine.d.ts +4 -3
- package/dist/frameworks/jasmine.js +13 -3
- package/dist/frameworks/mocha.js +3 -2
- package/dist/frameworks/node.js +11 -8
- package/dist/frameworks/playwright.d.ts +5 -0
- package/dist/frameworks/playwright.js +27 -0
- package/dist/frameworks/test-functions.js +9 -0
- package/dist/node-scripts.d.ts +5 -0
- package/dist/node-scripts.js +53 -2
- package/dist/records.d.ts +2 -0
- package/dist/records.js +45 -15
- package/dist/resolve.d.ts +7 -1
- package/dist/resolve.js +16 -4
- package/dist/scan-file.js +2 -0
- package/dist/toml.js +10 -3
- package/dist/yaml.d.ts +2 -1
- package/dist/yaml.js +174 -35
- package/package.json +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,105 @@
|
|
|
1
1
|
# test-inventory
|
|
2
2
|
|
|
3
|
+
## 0.9.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#92](https://github.com/Huldoser/test-inventory/pull/92) [`0001eea`](https://github.com/Huldoser/test-inventory/commit/0001eeac49b8b7ae0c675ae12c1aa8d29daf17ff) - Bun: a test whose function is passed by name, followed by a timeout or options, as in
|
|
8
|
+
`test('reprices a basket', repricesBasket, 5_000)`, is read as a test. The scan took the timeout for the function and
|
|
9
|
+
reported a `test-without-body` error, listing every test in the file as not loaded, though Bun runs them.
|
|
10
|
+
|
|
11
|
+
- [#92](https://github.com/Huldoser/test-inventory/pull/92) [`0001eea`](https://github.com/Huldoser/test-inventory/commit/0001eeac49b8b7ae0c675ae12c1aa8d29daf17ff) - A `__proto__` key in a `bunfig.toml` or `.mocharc.yml` is read as a plain key, as Bun and Mocha read it. A
|
|
12
|
+
`bunfig.toml` with a `[__proto__]` table changed `Object.prototype` for the whole process, so every later scan in it,
|
|
13
|
+
such as those of a long-running MCP server, read settings the project never set. A `.mocharc.yml` one gave its map the
|
|
14
|
+
settings inside it. TOML keys named `constructor` or `toString` are read too, where they were refused.
|
|
15
|
+
|
|
16
|
+
- [#92](https://github.com/Huldoser/test-inventory/pull/92) [`0001eea`](https://github.com/Huldoser/test-inventory/commit/0001eeac49b8b7ae0c675ae12c1aa8d29daf17ff) - Cypress: `specPattern` and `excludeSpecPattern` are read as globby, which Cypress uses, reads them. A `specPattern` that
|
|
17
|
+
starts with `!` leaves files out, where the scan took it to match every other file and listed nearly the whole project;
|
|
18
|
+
an `excludeSpecPattern` drops its `!`, where the scan left out everything else; and a folder in either stands for every
|
|
19
|
+
file below it, where it matched nothing.
|
|
20
|
+
|
|
21
|
+
- [#92](https://github.com/Huldoser/test-inventory/pull/92) [`0001eea`](https://github.com/Huldoser/test-inventory/commit/0001eeac49b8b7ae0c675ae12c1aa8d29daf17ff) - Jasmine: a describe callback with a TypeScript `this` parameter, a parameter with a default value or a rest parameter,
|
|
22
|
+
as `function (this: object)`, is no longer reported as taking arguments. Jasmine checks the function's `length`, which
|
|
23
|
+
counts none of these, and runs the specs; the scan listed them as not loaded.
|
|
24
|
+
|
|
25
|
+
- [#92](https://github.com/Huldoser/test-inventory/pull/92) [`0001eea`](https://github.com/Huldoser/test-inventory/commit/0001eeac49b8b7ae0c675ae12c1aa8d29daf17ff) - Jasmine: an `xdescribe` inside an `fdescribe` stays skipped, as in Jasmine, where the scan listed its specs as active;
|
|
26
|
+
a focus inside the `xdescribe` still runs. WebdriverIO on Jasmine now follows Jasmine's focus rules: a `fit` inside an
|
|
27
|
+
`xdescribe` runs, and in an `fdescribe` with a `fit` below it only the `fit` has `isOnly`, where the scan applied
|
|
28
|
+
Mocha's rules.
|
|
29
|
+
|
|
30
|
+
- [#92](https://github.com/Huldoser/test-inventory/pull/92) [`0001eea`](https://github.com/Huldoser/test-inventory/commit/0001eeac49b8b7ae0c675ae12c1aa8d29daf17ff) - A `<rootDir>` entry in Jest's `moduleDirectories`, as `['node_modules', '<rootDir>/src']`, is followed as a folder to
|
|
31
|
+
look in, as Jest does. The scan looked for a folder named `<rootDir>/src` and left the files out of `dependencies`
|
|
32
|
+
without a warning.
|
|
33
|
+
|
|
34
|
+
- [#92](https://github.com/Huldoser/test-inventory/pull/92) [`0001eea`](https://github.com/Huldoser/test-inventory/commit/0001eeac49b8b7ae0c675ae12c1aa8d29daf17ff) - Jest's `moduleNameMapper` replaces the whole import name, as Jest does, also when its pattern matches only part of it,
|
|
35
|
+
as `'\\.css$'` does. The scan replaced only the matched part, so a mapped style or file mock was missing from
|
|
36
|
+
`dependencies` and its import got a `dependency-not-followed` warning. Vite's aliases still replace only the part they
|
|
37
|
+
match.
|
|
38
|
+
|
|
39
|
+
- [#92](https://github.com/Huldoser/test-inventory/pull/92) [`0001eea`](https://github.com/Huldoser/test-inventory/commit/0001eeac49b8b7ae0c675ae12c1aa8d29daf17ff) - Test files reached through a symbolic link are read the way each runner reads them. Jasmine and Bun follow such links
|
|
40
|
+
and run the file once, as Vitest and Mocha do, so the file is no longer left out; Bun names it by its own path, as its
|
|
41
|
+
reports do. node:test runs a linked file, twice when its own path matches too, but a wildcard in its pattern doesn't
|
|
42
|
+
enter a linked folder. The `symlink-ignored` warning now names the runner in use, where it named Playwright for every
|
|
43
|
+
runner but Jest.
|
|
44
|
+
|
|
45
|
+
- [#92](https://github.com/Huldoser/test-inventory/pull/92) [`0001eea`](https://github.com/Huldoser/test-inventory/commit/0001eeac49b8b7ae0c675ae12c1aa8d29daf17ff) - Mocha: an absolute glob in `spec`, as a `.mocharc.js` builds it with `path.join(__dirname, 'test', '**', '*.spec.js')`,
|
|
46
|
+
runs the files it matches. The scan matched it against paths relative to the config's folder, found nothing, and
|
|
47
|
+
reported `no-files-matched`.
|
|
48
|
+
|
|
49
|
+
- [#92](https://github.com/Huldoser/test-inventory/pull/92) [`0001eea`](https://github.com/Huldoser/test-inventory/commit/0001eeac49b8b7ae0c675ae12c1aa8d29daf17ff) - Mocha, Cypress and WebdriverIO on Mocha: `this.skip()` in an `afterEach` hook no longer marks the tests as skipped.
|
|
50
|
+
The test has passed by the time the hook runs, and Mocha reports it as a pass.
|
|
51
|
+
|
|
52
|
+
- [#92](https://github.com/Huldoser/test-inventory/pull/92) [`0001eea`](https://github.com/Huldoser/test-inventory/commit/0001eeac49b8b7ae0c675ae12c1aa8d29daf17ff) - Mocha: a `.only` in a project whose config sets `forbid-only` (or `forbidOnly`) gets a `forbidden-only` error, as Mocha
|
|
53
|
+
stops the run before any test runs, or a warning when the setting depends on a condition, as Playwright's `forbidOnly`
|
|
54
|
+
does.
|
|
55
|
+
|
|
56
|
+
- [#92](https://github.com/Huldoser/test-inventory/pull/92) [`0001eea`](https://github.com/Huldoser/test-inventory/commit/0001eeac49b8b7ae0c675ae12c1aa8d29daf17ff) - A `.mocharc.yml` is read as js-yaml, Mocha's reader, reads it. Files that Mocha reads and the scan refused, which lost
|
|
57
|
+
every setting and so the files to test, are now read: a byte order mark, a comment or a `%YAML` line before `---`, a
|
|
58
|
+
`...` at the end, quoted list items with commas, as `['test/**/*.{ts,js}']`, YAML's escapes in double quotes, as
|
|
59
|
+
`\x41`, and a tab or an escaped quote followed by ` #` in quotes. A quote inside a value, as in `grep: buy 'limit # note`,
|
|
60
|
+
no longer hides the comment after it, `-a.js` on its own line is a value, not a list item, and what Mocha refuses is
|
|
61
|
+
reported rather than read: a key set twice, a tab in the indent, `a: b` in a value, a list inside a list, and values
|
|
62
|
+
that start with `@`, `` ` `` or `%`. `-.5` is a string, as js-yaml reads it. A long line is read in linear time; one of
|
|
63
|
+
160 KB took 5 seconds.
|
|
64
|
+
|
|
65
|
+
- [#92](https://github.com/Huldoser/test-inventory/pull/92) [`0001eea`](https://github.com/Huldoser/test-inventory/commit/0001eeac49b8b7ae0c675ae12c1aa8d29daf17ff) - node:test and Bun: a skipped describe skips every test inside it, over the test's own todo, as node:test creates none of
|
|
66
|
+
them, and in Bun the outermost skipped or todo describe decides, over the describes inside it and the test's own state.
|
|
67
|
+
The scan took the state nearest the test, so `test.todo()` in `describe.skip()` was todo, and in Bun `test.skip()` in
|
|
68
|
+
`describe.todo()` was skipped.
|
|
69
|
+
|
|
70
|
+
- [#92](https://github.com/Huldoser/test-inventory/pull/92) [`0001eea`](https://github.com/Huldoser/test-inventory/commit/0001eeac49b8b7ae0c675ae12c1aa8d29daf17ff) - node:test: a test whose function is passed by name, as `test('fills a market order', fillsMarketOrder)` or
|
|
71
|
+
`test(fillsMarketOrder)`, gets that function's `bodyHash`, and without a title the function's name, as Node.js names it.
|
|
72
|
+
The scan took the function for the test's options, with an `unresolved-option` warning and no hash, or for a title it
|
|
73
|
+
couldn't work out.
|
|
74
|
+
|
|
75
|
+
- [#92](https://github.com/Huldoser/test-inventory/pull/92) [`0001eea`](https://github.com/Huldoser/test-inventory/commit/0001eeac49b8b7ae0c675ae12c1aa8d29daf17ff) - node:test: the scan reads the `node --test` commands of every script the `test` script runs through `npm run`, `pnpm`,
|
|
76
|
+
`yarn`, `bun run`, `npm-run-all`, `run-s` or `run-p`, as in `"test": "npm run test:unit && npm run test:integration"`.
|
|
77
|
+
It read only the first script that runs `node --test`, and left out the files of the others without a warning.
|
|
78
|
+
|
|
79
|
+
- [#92](https://github.com/Huldoser/test-inventory/pull/92) [`0001eea`](https://github.com/Huldoser/test-inventory/commit/0001eeac49b8b7ae0c675ae12c1aa8d29daf17ff) - From Playwright 1.65, `test.skip('reason')`, `test.fixme('reason')` and `test.fail('reason')` with only a string give
|
|
80
|
+
that string as the record's `reason`, in a test body and at file or describe level, and no longer a `skip-without-body`
|
|
81
|
+
warning, as Playwright 1.65 takes the string as the description. An empty string still applies nothing. Older versions
|
|
82
|
+
keep the old reading.
|
|
83
|
+
|
|
84
|
+
- [#92](https://github.com/Huldoser/test-inventory/pull/92) [`0001eea`](https://github.com/Huldoser/test-inventory/commit/0001eeac49b8b7ae0c675ae12c1aa8d29daf17ff) - A `dependency-not-followed` warning for an import a config maps to a file that doesn't exist gives that file's path
|
|
85
|
+
relative to the root, as every path in the output is. It gave the absolute path, as `path.resolve()` or `<rootDir>`
|
|
86
|
+
built it, so the output differed from machine to machine.
|
|
87
|
+
|
|
88
|
+
- [#92](https://github.com/Huldoser/test-inventory/pull/92) [`0001eea`](https://github.com/Huldoser/test-inventory/commit/0001eeac49b8b7ae0c675ae12c1aa8d29daf17ff) - A test or describe function chosen in place, as in `(process.env.CI ? it.skip : it)('books a fill', ...)` or
|
|
89
|
+
`(process.env.CI && it.skip || it)(...)`, is read as one kept in a variable: only what both choices share applies. The
|
|
90
|
+
scan dropped these tests without a warning, for every runner but Playwright, whose case is still open. Jasmine
|
|
91
|
+
variables that hold `xit`, `fit`, `xdescribe` or `fdescribe`, as `const later = xit`, keep the `x` or `f`, as the docs
|
|
92
|
+
said; their tests were dropped too.
|
|
93
|
+
|
|
94
|
+
- [#92](https://github.com/Huldoser/test-inventory/pull/92) [`0001eea`](https://github.com/Huldoser/test-inventory/commit/0001eeac49b8b7ae0c675ae12c1aa8d29daf17ff) - A Vite alias to a path that starts with `/`, as `alias: { '@': '/src' }`, is followed from the project's root, as Vite
|
|
95
|
+
does, so `dependencies` and `dependencyHash` include the files imported through it. The scan looked for `/src` on the
|
|
96
|
+
disk, gave a `dependency-not-followed` warning and left the files out.
|
|
97
|
+
|
|
98
|
+
- [#92](https://github.com/Huldoser/test-inventory/pull/92) [`0001eea`](https://github.com/Huldoser/test-inventory/commit/0001eeac49b8b7ae0c675ae12c1aa8d29daf17ff) - WebdriverIO: a `specs` or `exclude` glob that starts with `!` matches no file, as in WebdriverIO, where the scan took it
|
|
99
|
+
to match every other file; a glob that starts with `./` matches from the config's folder only, as its slash keeps glob's
|
|
100
|
+
`matchBase` off; from WebdriverIO 10 a capability's `specs` and `exclude` are no longer read, only `wdio:specs` and
|
|
101
|
+
`wdio:exclude`; and a capability's settings inside `alwaysMatch` are read.
|
|
102
|
+
|
|
3
103
|
## 0.9.0
|
|
4
104
|
|
|
5
105
|
### Minor Changes
|
package/dist/config-runs.d.ts
CHANGED
|
@@ -136,9 +136,9 @@ export declare class ConfigRuns {
|
|
|
136
136
|
private placeNode;
|
|
137
137
|
/**
|
|
138
138
|
* The files `node --test` runs from the root, outside dot folders and `node_modules`: those the arguments of the
|
|
139
|
-
*
|
|
140
|
-
* for the default patterns inside it; without arguments, the default patterns. They take
|
|
141
|
-
* Node.js 22.18, which strips types by default.
|
|
139
|
+
* `test` script and the scripts it runs give, or the first script that runs it, each a glob or a path, and from
|
|
140
|
+
* Node.js 26.8 a folder for the default patterns inside it; without arguments, the default patterns. They take
|
|
141
|
+
* TypeScript files too from Node.js 22.18, which strips types by default.
|
|
142
142
|
*/
|
|
143
143
|
private nodeFiles;
|
|
144
144
|
/** WebdriverIO runs the files of the config in the root; without one, it runs nothing, unless it is given files. */
|
package/dist/config-runs.js
CHANGED
|
@@ -5,7 +5,7 @@ import picomatch from 'picomatch';
|
|
|
5
5
|
import { globSync } from 'tinyglobby';
|
|
6
6
|
import { mergeDeep, settingAt, unknownText, } from "./config.js";
|
|
7
7
|
import { atLeast } from "./frameworks/common.js";
|
|
8
|
-
import { nodeTestCommands } from "./node-scripts.js";
|
|
8
|
+
import { nodeTestCommands, scriptsRunBy } from "./node-scripts.js";
|
|
9
9
|
import { durationOf } from "./frameworks/mocha.js";
|
|
10
10
|
import { VITEST_BENCHMARK_INCLUDE, VITEST_INCLUDE, VITEST_TYPECHECK_INCLUDE, vitestExclude, } from "./vitest-defaults.js";
|
|
11
11
|
const PLAYWRIGHT_TEST_MATCH = '**/*.@(spec|test).?(c|m)[jt]s?(x)';
|
|
@@ -427,8 +427,18 @@ export class ConfigRuns {
|
|
|
427
427
|
const [specs, excludes] = lists;
|
|
428
428
|
if (type === 'e2e')
|
|
429
429
|
e2eSpecs = specs;
|
|
430
|
-
|
|
431
|
-
|
|
430
|
+
// globby takes a `!` pattern among the specs as files to leave out, and a folder as every file below it; the
|
|
431
|
+
// excludes are fast-glob's `ignore`, which drops a `!` and skips everything in a folder it matches.
|
|
432
|
+
const below = (glob) => [glob, `${glob.replace(/\/+$/, '')}/**`];
|
|
433
|
+
const isFolder = (glob) => !picomatch.scan(glob).isGlob && statSync(path.resolve(folder, glob), { throwIfNoEntry: false })?.isDirectory();
|
|
434
|
+
const isSpec = picomatch(specs
|
|
435
|
+
.filter((glob) => !glob.startsWith('!'))
|
|
436
|
+
.map(relative)
|
|
437
|
+
.flatMap((glob) => (isFolder(glob) ? below(glob) : [glob])));
|
|
438
|
+
const excluded = [...excludes, ...(type === 'component' ? e2eSpecs : [])]
|
|
439
|
+
.map((glob) => relative(glob.replace(/^!/, '')))
|
|
440
|
+
.flatMap(below);
|
|
441
|
+
excluded.push(...specs.filter((glob) => glob.startsWith('!')).flatMap((glob) => below(relative(glob.slice(1)))));
|
|
432
442
|
if (!specs.some((glob) => glob.includes('node_modules')))
|
|
433
443
|
excluded.push('**/node_modules/**');
|
|
434
444
|
const isExcluded = picomatch(excluded, { dot: true });
|
|
@@ -552,9 +562,9 @@ export class ConfigRuns {
|
|
|
552
562
|
}
|
|
553
563
|
/**
|
|
554
564
|
* The files `node --test` runs from the root, outside dot folders and `node_modules`: those the arguments of the
|
|
555
|
-
*
|
|
556
|
-
* for the default patterns inside it; without arguments, the default patterns. They take
|
|
557
|
-
* Node.js 22.18, which strips types by default.
|
|
565
|
+
* `test` script and the scripts it runs give, or the first script that runs it, each a glob or a path, and from
|
|
566
|
+
* Node.js 26.8 a folder for the default patterns inside it; without arguments, the default patterns. They take
|
|
567
|
+
* TypeScript files too from Node.js 22.18, which strips types by default.
|
|
558
568
|
*/
|
|
559
569
|
nodeFiles() {
|
|
560
570
|
const extensions = stripsTypes(this.version) ? 'cjs,mjs,js,cts,mts,ts' : 'cjs,mjs,js';
|
|
@@ -622,8 +632,11 @@ export class ConfigRuns {
|
|
|
622
632
|
const slashed = glob.replaceAll('\\', '/');
|
|
623
633
|
return path.posix.normalize(path.isAbsolute(slashed) ? posix(path.relative(folder, slashed)) : slashed);
|
|
624
634
|
};
|
|
625
|
-
// As glob's matchBase does, a pattern without a slash matches at any depth, outside dot folders too
|
|
626
|
-
|
|
635
|
+
// As glob's matchBase does, a pattern without a slash matches at any depth, outside dot folders too; the slash of
|
|
636
|
+
// `./` counts. A pattern that starts with `!` matches no file in glob.
|
|
637
|
+
const matcher = (list) => picomatch(list
|
|
638
|
+
.filter((glob) => !glob.startsWith('!'))
|
|
639
|
+
.map((glob) => (/[/\\]/.test(glob) ? fromRoot(glob) : `**/${fromRoot(glob)}`)));
|
|
627
640
|
const specs = globs(settings, ['specs']) ?? [];
|
|
628
641
|
if (!Array.isArray(specs))
|
|
629
642
|
return this.unknownProject(config, specs, 'specs');
|
|
@@ -634,16 +647,24 @@ export class ConfigRuns {
|
|
|
634
647
|
const isGlob = excludes.every((item) => /[/\\*]/.test(item));
|
|
635
648
|
const isPathExcluded = matcher(excludes);
|
|
636
649
|
const isExcluded = (file, relative) => isGlob ? isPathExcluded(relative) : excludes.some((item) => pathToFileURL(file).href.includes(item));
|
|
637
|
-
// Each capability may set its own specs, which replace the config's, and excludes, added to the config's
|
|
650
|
+
// Each capability may set its own specs, which replace the config's, and excludes, added to the config's, inside
|
|
651
|
+
// `alwaysMatch` when it has one. WebdriverIO 10 reads only `wdio:specs` and `wdio:exclude`.
|
|
638
652
|
const capabilities = settingAt(settings, ['capabilities']);
|
|
653
|
+
const [specKeys, excludeKeys] = atLeast(this.version, 10, 0)
|
|
654
|
+
? [['wdio:specs'], ['wdio:exclude']]
|
|
655
|
+
: [
|
|
656
|
+
['specs', 'wdio:specs'],
|
|
657
|
+
['exclude', 'wdio:exclude'],
|
|
658
|
+
];
|
|
639
659
|
const runs = [];
|
|
640
660
|
for (const capability of capabilities?.kind === 'list' && capabilities.items.length > 0
|
|
641
661
|
? capabilities.items
|
|
642
662
|
: [emptySettings()]) {
|
|
643
|
-
const
|
|
663
|
+
const options = settingAt(capability, ['alwaysMatch']) ?? capability;
|
|
664
|
+
const own = globs(options, specKeys);
|
|
644
665
|
if (own !== null && !Array.isArray(own))
|
|
645
666
|
return this.unknownProject(config, own, 'capabilities.specs');
|
|
646
|
-
const exclude = globs(
|
|
667
|
+
const exclude = globs(options, excludeKeys) ?? [];
|
|
647
668
|
if (!Array.isArray(exclude))
|
|
648
669
|
return this.unknownProject(config, exclude, 'capabilities.exclude');
|
|
649
670
|
runs.push({ isSpec: matcher(own ?? specs), isExcluded: matcher(exclude) });
|
|
@@ -1454,7 +1475,9 @@ function writtenRoot(settings) {
|
|
|
1454
1475
|
function mochaSpec(folder, spec, extensions, recursive) {
|
|
1455
1476
|
const target = path.resolve(folder, spec);
|
|
1456
1477
|
if (picomatch.scan(posix(spec)).isGlob) {
|
|
1457
|
-
|
|
1478
|
+
// An absolute glob, as `path.join(__dirname, 'test', '**', '*.spec.js')` builds it, is taken from the folder.
|
|
1479
|
+
const written = path.isAbsolute(spec) ? path.relative(folder, spec) : spec;
|
|
1480
|
+
const isMatch = picomatch(posix(written).replace(/^\.\//, ''));
|
|
1458
1481
|
return (file) => isMatch(posix(path.relative(folder, file)));
|
|
1459
1482
|
}
|
|
1460
1483
|
const stat = statSync(target, { throwIfNoEntry: false });
|
|
@@ -1704,21 +1727,23 @@ export function fileConfig(placement, framework, version, file) {
|
|
|
1704
1727
|
};
|
|
1705
1728
|
}
|
|
1706
1729
|
/**
|
|
1707
|
-
* Why a `.only` fails: with Playwright's `forbidOnly`, the run, before any test; with Vitest's
|
|
1708
|
-
* test itself, which Vitest marks failed instead of running it (checked in 3.2.4, 4.1.12 and
|
|
1709
|
-
* off by default when `process.env.CI` is set. Null when nothing fails.
|
|
1730
|
+
* Why a `.only` fails: with Playwright's `forbidOnly` or Mocha's `forbid-only`, the run, before any test; with Vitest's
|
|
1731
|
+
* `allowOnly` off, the test itself, which Vitest marks failed instead of running it (checked in 3.2.4, 4.1.12 and
|
|
1732
|
+
* 5.1.0). `allowOnly` is off by default when `process.env.CI` is set. Null when nothing fails.
|
|
1710
1733
|
*/
|
|
1711
1734
|
function onlyRule(framework, settings) {
|
|
1712
|
-
if (framework === 'playwright') {
|
|
1713
|
-
|
|
1735
|
+
if (framework === 'playwright' || framework === 'mocha') {
|
|
1736
|
+
// Mocha takes its options in kebab case or camel case.
|
|
1737
|
+
const [name, keys] = framework === 'mocha' ? ['forbid-only', ['forbid-only', 'forbidOnly']] : ['forbidOnly', ['forbidOnly']];
|
|
1738
|
+
const forbid = settings && keys.map((key) => settingAt(settings, [key])).find((setting) => setting !== null);
|
|
1714
1739
|
const condition = forbid?.kind === 'unknown' ? unknownText(forbid) : null;
|
|
1715
1740
|
if (condition) {
|
|
1716
|
-
const message = `The config sets
|
|
1741
|
+
const message = `The config sets ${name} when ${condition}, so then this .only fails the run before any test runs.`;
|
|
1717
1742
|
return { message, isSure: false };
|
|
1718
1743
|
}
|
|
1719
1744
|
if (forbid?.kind !== 'value' || forbid.value !== true)
|
|
1720
1745
|
return null;
|
|
1721
|
-
return { message:
|
|
1746
|
+
return { message: `The config sets ${name}, so this .only fails the run before any test runs.`, isSure: true };
|
|
1722
1747
|
}
|
|
1723
1748
|
if (framework !== 'vitest')
|
|
1724
1749
|
return null;
|
|
@@ -1867,8 +1892,9 @@ export function importMap(placement, framework) {
|
|
|
1867
1892
|
}
|
|
1868
1893
|
const importMaps = new WeakMap();
|
|
1869
1894
|
function readImportMap(config, settings, placement, framework) {
|
|
1870
|
-
const map = { aliases: [], paths: [], directories: [] };
|
|
1895
|
+
const map = { aliases: [], paths: [], directories: [], root: null };
|
|
1871
1896
|
if (framework === 'vitest') {
|
|
1897
|
+
map.root = placement.projects?.[0]?.root ?? path.dirname(config.file);
|
|
1872
1898
|
const sources = settings === config.settings ? [settings] : [settings, config.settings];
|
|
1873
1899
|
for (const source of sources) {
|
|
1874
1900
|
for (const key of [
|
|
@@ -1885,10 +1911,17 @@ function readImportMap(config, settings, placement, framework) {
|
|
|
1885
1911
|
const replacements = (target.kind === 'list' ? strings(target) : stringOf(target)).map((item) => replaceRootDir(rootDir, item));
|
|
1886
1912
|
const find = regExp(pattern, '');
|
|
1887
1913
|
if (find && replacements.length > 0)
|
|
1888
|
-
map.aliases.push({ find, replacements });
|
|
1914
|
+
map.aliases.push({ find, replacements, replacesName: true });
|
|
1889
1915
|
}
|
|
1890
1916
|
map.paths = strings(settingAt(settings, ['modulePaths'])).map((item) => path.resolve(rootDir, replaceRootDir(rootDir, item)));
|
|
1891
|
-
|
|
1917
|
+
// A `<rootDir>` entry of moduleDirectories is a folder, as a modulePaths entry is, not a name to look for.
|
|
1918
|
+
for (const item of strings(settingAt(settings, ['moduleDirectories']))) {
|
|
1919
|
+
const directory = replaceRootDir(rootDir, item);
|
|
1920
|
+
if (path.isAbsolute(directory))
|
|
1921
|
+
map.paths.push(directory);
|
|
1922
|
+
else if (directory !== 'node_modules')
|
|
1923
|
+
map.directories.push(directory);
|
|
1924
|
+
}
|
|
1892
1925
|
}
|
|
1893
1926
|
return map.aliases.length + map.paths.length + map.directories.length > 0 ? map : null;
|
|
1894
1927
|
}
|
|
@@ -1898,7 +1931,7 @@ function readImportMap(config, settings, placement, framework) {
|
|
|
1898
1931
|
*/
|
|
1899
1932
|
function viteAliases(setting) {
|
|
1900
1933
|
if (setting?.kind === 'object') {
|
|
1901
|
-
return [...setting.keys].flatMap(([find, target]) => stringOf(target).map((replacement) => ({ find, replacements: [replacement] })));
|
|
1934
|
+
return [...setting.keys].flatMap(([find, target]) => stringOf(target).map((replacement) => ({ find, replacements: [replacement], replacesName: false })));
|
|
1902
1935
|
}
|
|
1903
1936
|
if (setting?.kind !== 'list')
|
|
1904
1937
|
return [];
|
|
@@ -1908,7 +1941,7 @@ function viteAliases(setting) {
|
|
|
1908
1941
|
const name = find?.kind === 'value' && typeof find.value === 'string' ? find.value : null;
|
|
1909
1942
|
const pattern = find?.kind === 'regex' ? regExp(find.source, find.flags) : null;
|
|
1910
1943
|
const written = name ?? pattern;
|
|
1911
|
-
return written !== null && replacements.length > 0 ? [{ find: written, replacements }] : [];
|
|
1944
|
+
return written !== null && replacements.length > 0 ? [{ find: written, replacements, replacesName: false }] : [];
|
|
1912
1945
|
});
|
|
1913
1946
|
}
|
|
1914
1947
|
/** A setting's string as a list of one; empty for anything else. */
|
|
@@ -1923,8 +1956,8 @@ function stripsTypes(version) {
|
|
|
1923
1956
|
return major > 23 || (major === 23 && minor >= 6) || (major === 22 && minor >= 18);
|
|
1924
1957
|
}
|
|
1925
1958
|
/**
|
|
1926
|
-
* The `node --test` commands of the
|
|
1927
|
-
* files it gives; none when no script runs it or there is no package.json.
|
|
1959
|
+
* The `node --test` commands of the `test` script and the scripts it runs, or else of the first script that runs one,
|
|
1960
|
+
* each as the files it gives; none when no script runs it or there is no package.json.
|
|
1928
1961
|
*/
|
|
1929
1962
|
function nodeTestArguments(manifest) {
|
|
1930
1963
|
let scripts = {};
|
|
@@ -1934,10 +1967,9 @@ function nodeTestArguments(manifest) {
|
|
|
1934
1967
|
catch {
|
|
1935
1968
|
return [];
|
|
1936
1969
|
}
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
return [];
|
|
1970
|
+
const fromTest = scriptsRunBy(scripts, 'test').flatMap(nodeTestCommands);
|
|
1971
|
+
if (fromTest.length > 0)
|
|
1972
|
+
return fromTest;
|
|
1973
|
+
const others = Object.values(scripts).filter((script) => typeof script === 'string');
|
|
1974
|
+
return others.map(nodeTestCommands).find((commands) => commands.length > 0) ?? [];
|
|
1943
1975
|
}
|
package/dist/files.d.ts
CHANGED
|
@@ -9,8 +9,9 @@ export interface FoundFile {
|
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Finds the test files, sorted so the output is the same on every run. Files reached through a symbolic link are
|
|
12
|
-
* left out for
|
|
13
|
-
* when
|
|
12
|
+
* left out for runners that don't follow links, and read once for those that do, from the file's own path when it
|
|
13
|
+
* matches too. Bun names such a file by its own path even when only the link matches, and node:test, which runs each
|
|
14
|
+
* file in a process of its own, runs a file matched by both paths twice.
|
|
14
15
|
*/
|
|
15
16
|
export declare function findFiles(root: string, patterns: string[], ignore: string[], framework: Framework, platform?: NodeJS.Platform): Promise<{
|
|
16
17
|
files: FoundFile[];
|
package/dist/files.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { readdir, realpath, realpathSync } from 'node:fs';
|
|
1
|
+
import { lstatSync, readdir, realpath, realpathSync } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import picomatch from 'picomatch';
|
|
3
4
|
import { glob } from 'tinyglobby';
|
|
4
5
|
import { fileDiagnostic } from "./diagnostics.js";
|
|
6
|
+
import { FRAMEWORK_NAMES } from "./framework-version.js";
|
|
5
7
|
const EXTENSIONS = /\.[cm]?[jt]sx?$/;
|
|
6
8
|
/** On Windows a `\` in a pattern is a path separator, as people type it there; elsewhere it escapes a character. */
|
|
7
9
|
export function normalizePattern(pattern, platform = process.platform) {
|
|
@@ -38,10 +40,39 @@ function recordingFs(failures) {
|
|
|
38
40
|
}),
|
|
39
41
|
};
|
|
40
42
|
}
|
|
43
|
+
/** Runners that load a test file reached through a symbolic link; Playwright and Jest don't. */
|
|
44
|
+
const FOLLOWS_LINKS = new Set(['vitest', 'mocha', 'jasmine', 'bun', 'node']);
|
|
45
|
+
/** Runners checked to leave such a file out; for the others, Cypress and WebdriverIO, it is not known. */
|
|
46
|
+
const IGNORES_LINKS = new Set(['playwright', 'jest']);
|
|
47
|
+
/**
|
|
48
|
+
* Whether a file is in a linked folder that no pattern names. `node --test` finds files with Node.js's glob, which
|
|
49
|
+
* doesn't enter a linked folder through `*` or `**`, only where a pattern spells out its name.
|
|
50
|
+
*/
|
|
51
|
+
function inUnnamedLinkedFolder(root, match, patterns) {
|
|
52
|
+
const segments = match.split('/');
|
|
53
|
+
for (let index = 0; index < segments.length - 1; index++) {
|
|
54
|
+
if (!lstatSync(path.join(root, ...segments.slice(0, index + 1))).isSymbolicLink())
|
|
55
|
+
continue;
|
|
56
|
+
if (!patterns.some((pattern) => namesFolder(pattern, segments, index)))
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
/** Whether a pattern matches the file with the folder at `index` matched by a part that is its name, not a wildcard. */
|
|
62
|
+
function namesFolder(pattern, segments, index) {
|
|
63
|
+
const parts = pattern.replace(/^\.\//, '').split('/');
|
|
64
|
+
const matches = (glob, items) => picomatch(glob.join('/'), { dot: true })(items.join('/'));
|
|
65
|
+
return parts.some((part, at) => at < parts.length - 1 &&
|
|
66
|
+
part === segments[index] &&
|
|
67
|
+
!picomatch.scan(part).isGlob &&
|
|
68
|
+
matches(parts.slice(0, at + 1), segments.slice(0, index + 1)) &&
|
|
69
|
+
matches(parts.slice(at + 1), segments.slice(index + 1)));
|
|
70
|
+
}
|
|
41
71
|
/**
|
|
42
72
|
* Finds the test files, sorted so the output is the same on every run. Files reached through a symbolic link are
|
|
43
|
-
* left out for
|
|
44
|
-
* when
|
|
73
|
+
* left out for runners that don't follow links, and read once for those that do, from the file's own path when it
|
|
74
|
+
* matches too. Bun names such a file by its own path even when only the link matches, and node:test, which runs each
|
|
75
|
+
* file in a process of its own, runs a file matched by both paths twice.
|
|
45
76
|
*/
|
|
46
77
|
export async function findFiles(root, patterns, ignore, framework, platform = process.platform) {
|
|
47
78
|
const failures = [];
|
|
@@ -82,15 +113,27 @@ export async function findFiles(root, patterns, ignore, framework, platform = pr
|
|
|
82
113
|
const absolutePath = path.resolve(root, match);
|
|
83
114
|
const realPath = realpathSync(absolutePath);
|
|
84
115
|
const linked = realPath !== path.join(realRoot, match);
|
|
85
|
-
|
|
86
|
-
if (linked && framework
|
|
87
|
-
const
|
|
88
|
-
|
|
116
|
+
const name = FRAMEWORK_NAMES[framework];
|
|
117
|
+
if (linked && !FOLLOWS_LINKS.has(framework)) {
|
|
118
|
+
const message = IGNORES_LINKS.has(framework)
|
|
119
|
+
? `The file is reached through a symbolic link, which ${name} does not follow.`
|
|
120
|
+
: `The file is reached through a symbolic link, which the scan does not follow for ${name}.`;
|
|
121
|
+
diagnostics.push(fileDiagnostic('symlink-ignored', match, message));
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (linked && framework === 'node' && inUnnamedLinkedFolder(root, match, patterns)) {
|
|
125
|
+
const message = `The file is in a linked folder, which a wildcard in a ${name} pattern does not enter.`;
|
|
126
|
+
diagnostics.push(fileDiagnostic('symlink-ignored', match, message));
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const own = path.relative(realRoot, realPath).replaceAll('\\', '/');
|
|
130
|
+
if (linked && framework === 'bun' && !own.startsWith('../') && !path.isAbsolute(own)) {
|
|
131
|
+
candidates.push({ absolutePath: path.resolve(root, own), relativeFilePath: own, realPath, linked: false });
|
|
89
132
|
continue;
|
|
90
133
|
}
|
|
91
134
|
candidates.push({ absolutePath, relativeFilePath: match, realPath, linked });
|
|
92
135
|
}
|
|
93
|
-
//
|
|
136
|
+
// Other runners read a file once; when both a link and the file itself match, the file's own path is the one kept.
|
|
94
137
|
const kept = new Map();
|
|
95
138
|
for (const candidate of candidates) {
|
|
96
139
|
const current = kept.get(candidate.realPath);
|
|
@@ -98,7 +141,7 @@ export async function findFiles(root, patterns, ignore, framework, platform = pr
|
|
|
98
141
|
kept.set(candidate.realPath, candidate);
|
|
99
142
|
}
|
|
100
143
|
const files = candidates
|
|
101
|
-
.filter((candidate) => kept.get(candidate.realPath) === candidate)
|
|
144
|
+
.filter((candidate) => framework === 'node' || kept.get(candidate.realPath) === candidate)
|
|
102
145
|
.map(({ absolutePath, relativeFilePath }) => ({ absolutePath, relativeFilePath }));
|
|
103
146
|
return { files, diagnostics };
|
|
104
147
|
}
|
package/dist/frameworks/bun.d.ts
CHANGED
|
@@ -37,6 +37,8 @@ export declare class BunAdapter extends SuiteAdapter {
|
|
|
37
37
|
private options;
|
|
38
38
|
/** How many tests a table registers: one per item; null with a warning when the scan can't count them. */
|
|
39
39
|
private caseCount;
|
|
40
|
+
/** Whether an argument is a value that can't be a function: a literal, or a constant the scan works out. */
|
|
41
|
+
private isKnownValue;
|
|
40
42
|
/** The cases of a table the scan can work out: an item that is an array is spread into the arguments, another is one. */
|
|
41
43
|
private tableCases;
|
|
42
44
|
}
|
package/dist/frameworks/bun.js
CHANGED
|
@@ -114,9 +114,13 @@ export class BunAdapter extends SuiteAdapter {
|
|
|
114
114
|
if (titleProblem)
|
|
115
115
|
problems.push(titleProblem);
|
|
116
116
|
const spread = args.some((arg) => arg.type === 'SpreadElement');
|
|
117
|
-
// (title, fn, options) or (title, options, fn); a number is the timeout.
|
|
117
|
+
// (title, fn, options) or (title, options, fn), by whether the second is a function; a number is the timeout. A
|
|
118
|
+
// name the scan can't follow, as an imported function, is taken for the function unless the third is one.
|
|
118
119
|
const [second, third] = [args.at(1), args.at(2)];
|
|
119
|
-
const
|
|
120
|
+
const isFunction = (node) => isFunctionLike(node) || namedFunction(this.file, context.scopes, node) !== null;
|
|
121
|
+
const fnSecond = third === undefined ||
|
|
122
|
+
isFunction(second) ||
|
|
123
|
+
(!isFunction(third) && !this.isKnownValue(second, context));
|
|
120
124
|
const body = spread ? undefined : fnSecond ? second : third;
|
|
121
125
|
const options = spread ? undefined : fnSecond ? third : second;
|
|
122
126
|
const fn = isFunctionNode(body) ? body : null;
|
|
@@ -246,6 +250,10 @@ export class BunAdapter extends SuiteAdapter {
|
|
|
246
250
|
}
|
|
247
251
|
return length;
|
|
248
252
|
}
|
|
253
|
+
/** Whether an argument is a value that can't be a function: a literal, or a constant the scan works out. */
|
|
254
|
+
isKnownValue(node, context) {
|
|
255
|
+
return node.type !== 'SpreadElement' && (isValue(node) || this.file.values.resolve(node, context.scopes).ok);
|
|
256
|
+
}
|
|
249
257
|
/** The cases of a table the scan can work out: an item that is an array is spread into the arguments, another is one. */
|
|
250
258
|
tableCases(table, title, context) {
|
|
251
259
|
const first = table.args.at(0);
|
|
@@ -2,8 +2,8 @@ import type { CallExpression } from 'oxc-parser';
|
|
|
2
2
|
import type { ApiCall, CallContext, ModuleReader } from '../model.ts';
|
|
3
3
|
import type { ParsedFile } from '../parse.ts';
|
|
4
4
|
import type { HookCounts } from '../types.ts';
|
|
5
|
-
import { type FileContext } from './common.ts';
|
|
6
|
-
import { SuiteAdapter } from './test-functions.ts';
|
|
5
|
+
import { type FileContext, type Link } from './common.ts';
|
|
6
|
+
import { SuiteAdapter, type Kind } from './test-functions.ts';
|
|
7
7
|
export declare class JasmineAdapter extends SuiteAdapter {
|
|
8
8
|
/** What the runner does with a call it refuses at the top level of a file, as the end of a sentence. */
|
|
9
9
|
protected readonly refusedEffect: string;
|
|
@@ -11,7 +11,8 @@ export declare class JasmineAdapter extends SuiteAdapter {
|
|
|
11
11
|
protected readonly trailingRetries: boolean;
|
|
12
12
|
constructor(parsed: ParsedFile, file: FileContext, readModule: ModuleReader | null);
|
|
13
13
|
classify(call: CallExpression, context: CallContext): ApiCall | null;
|
|
14
|
-
|
|
14
|
+
/** `skip` and `only` are what `xit`, `fit`, `xdescribe` and `fdescribe` carry, so a variable may hold them. */
|
|
15
|
+
protected isAliasLink(_kind: Kind, link: Link): boolean;
|
|
15
16
|
protected hook(call: CallExpression, name: keyof HookCounts, context: CallContext): ApiCall;
|
|
16
17
|
/**
|
|
17
18
|
* `pending(reason)` in a spec or its `beforeEach` or `afterEach` hook, and from Jasmine 7 `notApplicable(reason)`,
|
|
@@ -42,8 +42,9 @@ export class JasmineAdapter extends SuiteAdapter {
|
|
|
42
42
|
classify(call, context) {
|
|
43
43
|
return this.pendingCall(call, context) ?? this.hookCall(call, context) ?? this.chainCall(call, context);
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
/** `skip` and `only` are what `xit`, `fit`, `xdescribe` and `fdescribe` carry, so a variable may hold them. */
|
|
46
|
+
isAliasLink(_kind, link) {
|
|
47
|
+
return link.name === 'skip' || link.name === 'only';
|
|
47
48
|
}
|
|
48
49
|
hook(call, name, context) {
|
|
49
50
|
const fn = hookFunction(this.file, context.scopes, call.arguments);
|
|
@@ -175,7 +176,7 @@ export class JasmineAdapter extends SuiteAdapter {
|
|
|
175
176
|
const refusal = this.refusal('describe-throws', fn, 'The describe declares no spec or describe, which Jasmine refuses', context);
|
|
176
177
|
return refused(call, refusal, context, () => declared);
|
|
177
178
|
}
|
|
178
|
-
if (fn && fn
|
|
179
|
+
if (fn && functionLength(fn) > 0) {
|
|
179
180
|
const refusal = this.refusal('describe-throws', fn, 'The describe callback takes arguments, which Jasmine refuses', context);
|
|
180
181
|
return refused(call, refusal, context, () => declared);
|
|
181
182
|
}
|
|
@@ -216,3 +217,12 @@ function isFunctionLike(node) {
|
|
|
216
217
|
const value = unwrap(node);
|
|
217
218
|
return !['Literal', 'ObjectExpression', 'ArrayExpression', 'TemplateLiteral'].includes(value.type);
|
|
218
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* A function's `length`, which Jasmine checks: its parameters before the first with a default value or a rest, without
|
|
222
|
+
* TypeScript's `this`, which is no parameter at run time.
|
|
223
|
+
*/
|
|
224
|
+
function functionLength(fn) {
|
|
225
|
+
const params = fn.params.filter((param) => param.type !== 'Identifier' || param.name !== 'this');
|
|
226
|
+
const end = params.findIndex((param) => param.type === 'AssignmentPattern' || param.type === 'RestElement');
|
|
227
|
+
return end === -1 ? params.length : end;
|
|
228
|
+
}
|
package/dist/frameworks/mocha.js
CHANGED
|
@@ -92,8 +92,9 @@ export class MochaAdapter extends SuiteAdapter {
|
|
|
92
92
|
}
|
|
93
93
|
hook(call, name, context) {
|
|
94
94
|
const fn = hookFunction(this.file, context.scopes, call.arguments);
|
|
95
|
-
// Mocha refuses `this.skip()` in an `after` hook, so the tests stay as they
|
|
96
|
-
|
|
95
|
+
// Mocha refuses `this.skip()` in an `after` hook, and in `afterEach` the test has passed, so the tests stay as they
|
|
96
|
+
// ran.
|
|
97
|
+
const testContext = name === 'afterAll' || name === 'afterEach' ? null : ownThis(fn);
|
|
97
98
|
return { kind: 'hook', name, fn, testContext, fixtures: [], takesAllFixtures: false };
|
|
98
99
|
}
|
|
99
100
|
/**
|
package/dist/frameworks/node.js
CHANGED
|
@@ -112,19 +112,21 @@ export class NodeAdapter extends SuiteAdapter {
|
|
|
112
112
|
return refused(call, problem('invalid-chain', call, message, callee), context, () => this.declaration(call, kind, [], context));
|
|
113
113
|
}
|
|
114
114
|
declaration(call, kind, links, context) {
|
|
115
|
-
const
|
|
115
|
+
const named = (node) => namedFunction(this.file, context.scopes, node) !== null;
|
|
116
|
+
const { name, options, body } = splitArguments(call.arguments, named);
|
|
116
117
|
const problems = [];
|
|
117
118
|
const fn = isFunctionNode(body) ? body : null;
|
|
118
119
|
let title = { text: '<anonymous>', withoutTags: '<anonymous>', isDynamic: false };
|
|
120
|
+
// Without a name, Node.js names the test after its function, which takes the name of the variable that holds it.
|
|
121
|
+
const fnName = fn?.id?.name ?? (body?.type === 'Identifier' ? body.name : null);
|
|
119
122
|
if (name) {
|
|
120
123
|
const read = readTitle(this.file, context.scopes, name, { stripTags: false, functionNames: false });
|
|
121
124
|
title = read.title;
|
|
122
125
|
if (read.problem)
|
|
123
126
|
problems.push(read.problem);
|
|
124
127
|
}
|
|
125
|
-
else if (
|
|
126
|
-
|
|
127
|
-
title = { text: fn.id.name, withoutTags: fn.id.name, isDynamic: false };
|
|
128
|
+
else if (fnName) {
|
|
129
|
+
title = { text: fnName, withoutTags: fnName, isDynamic: false };
|
|
128
130
|
}
|
|
129
131
|
const line = this.file.source.line(call.start);
|
|
130
132
|
const states = links
|
|
@@ -243,15 +245,16 @@ function stateFrom(file, state, option, line, takesReason) {
|
|
|
243
245
|
}
|
|
244
246
|
/**
|
|
245
247
|
* The name, options and function of a call, as Node.js reads `test([name][, options][, fn])`: a function first is the
|
|
246
|
-
* test's function, an object first its options.
|
|
248
|
+
* test's function, an object first its options. A function may be written in place or passed by a name `named` finds.
|
|
247
249
|
*/
|
|
248
|
-
function splitArguments(args) {
|
|
250
|
+
function splitArguments(args, named) {
|
|
249
251
|
const [first, second, third] = args;
|
|
250
|
-
|
|
252
|
+
const isFunction = (node) => node !== undefined && (isFunctionLike(node) || named(node));
|
|
253
|
+
if (isFunction(first))
|
|
251
254
|
return { name: undefined, options: undefined, body: first };
|
|
252
255
|
if (first && isObjectLike(first))
|
|
253
256
|
return { name: undefined, options: first, body: second };
|
|
254
|
-
if (
|
|
257
|
+
if (isFunction(second))
|
|
255
258
|
return { name: first, options: undefined, body: second };
|
|
256
259
|
return { name: first, options: second, body: third };
|
|
257
260
|
}
|
|
@@ -71,6 +71,11 @@ export declare class PlaywrightAdapter implements Adapter {
|
|
|
71
71
|
/** `test.step(title, body)` in a test body; a title that can't be worked out is kept as source text. */
|
|
72
72
|
private step;
|
|
73
73
|
private modifier;
|
|
74
|
+
/**
|
|
75
|
+
* From Playwright 1.65, `test.skip(description)` with a string: the string is the reason, and still a condition, so
|
|
76
|
+
* an empty one applies nothing. A template literal with text of its own is never empty.
|
|
77
|
+
*/
|
|
78
|
+
private describedModifier;
|
|
74
79
|
private describeCall;
|
|
75
80
|
private configure;
|
|
76
81
|
/** `test.setTimeout(ms)` or `test.slow(condition?, description?)`, which apply where they are called. */
|