eslint-plugin-test-governance 0.3.1 → 0.5.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +114 -1
  2. package/README.md +202 -83
  3. package/dist/index.d.ts +12 -11
  4. package/dist/index.js +28 -14
  5. package/dist/rules/marker-matches-state.d.ts +0 -1
  6. package/dist/rules/marker-matches-state.js +4 -4
  7. package/dist/rules/no-conflicting-states.d.ts +0 -1
  8. package/dist/rules/no-conflicting-states.js +17 -19
  9. package/dist/rules/no-orphaned-marker.d.ts +0 -1
  10. package/dist/rules/no-orphaned-marker.js +12 -7
  11. package/dist/rules/require-ticket-in-comments.d.ts +0 -1
  12. package/dist/rules/require-ticket-in-comments.js +8 -13
  13. package/dist/rules/require-ticket.d.ts +1 -2
  14. package/dist/rules/require-ticket.js +22 -10
  15. package/dist/utils/analyze.d.ts +29 -12
  16. package/dist/utils/analyze.js +526 -181
  17. package/dist/utils/constants.d.ts +5 -3
  18. package/dist/utils/constants.js +4 -3
  19. package/dist/utils/create-rule.d.ts +7 -8
  20. package/dist/utils/create-rule.js +3 -9
  21. package/dist/utils/distance.d.ts +0 -1
  22. package/dist/utils/distance.js +0 -1
  23. package/dist/utils/errors.d.ts +0 -1
  24. package/dist/utils/errors.js +0 -1
  25. package/dist/utils/fix.d.ts +0 -3
  26. package/dist/utils/fix.js +0 -8
  27. package/dist/utils/frameworks.d.ts +68 -0
  28. package/dist/utils/frameworks.js +108 -0
  29. package/dist/utils/options.d.ts +33 -12
  30. package/dist/utils/options.js +9 -5
  31. package/dist/utils/schema.d.ts +0 -1
  32. package/dist/utils/schema.js +9 -3
  33. package/dist/utils/tickets.d.ts +0 -1
  34. package/dist/utils/tickets.js +3 -3
  35. package/dist/utils/validate.d.ts +4 -1
  36. package/dist/utils/validate.js +9 -4
  37. package/docs/rules/marker-matches-state.md +19 -11
  38. package/docs/rules/no-conflicting-states.md +18 -10
  39. package/docs/rules/no-orphaned-marker.md +59 -18
  40. package/docs/rules/require-ticket-in-comments.md +27 -23
  41. package/docs/rules/require-ticket.md +135 -49
  42. package/docs/upgrading.md +131 -0
  43. package/package.json +5 -4
@@ -1,19 +1,27 @@
1
- const PLAYWRIGHT_MODULES = new Set(['@playwright/test', 'playwright/test']);
2
- /** Other test runners. A name imported from one of these is never Playwright's `test`. */
3
- const OTHER_FRAMEWORKS = new Set(['vitest', '@jest/globals', 'node:test', 'bun:test', 'mocha', 'ava', 'tap', 'uvu']);
4
- /** `@playwright/test` and the component-testing packages such as `@playwright/experimental-ct-react`. */
5
- function isPlaywrightModule(source) {
6
- return PLAYWRIGHT_MODULES.has(source) || source.startsWith('@playwright/experimental-ct-');
7
- }
8
- const TEST_MODIFIERS = new Set(['only', 'skip', 'fixme', 'fail', 'slow']);
9
- const DESCRIBE_MODIFIERS = new Set(['only', 'skip', 'fixme', 'serial', 'parallel']);
10
- const RUNTIME_MODIFIERS = new Set(['skip', 'fixme', 'fail', 'slow']);
11
- const SKIPPING_MODIFIERS = new Set(['skip', 'fixme']);
1
+ import { isOtherRunner, RUNTIME_MODIFIERS } from "./frameworks.js";
2
+ const TEST = { kind: 'test', modifiers: [] };
3
+ /** Modifiers that keep a test from running. */
4
+ const SKIPPING_MODIFIERS = new Set(['skip', 'fixme', 'todo']);
5
+ /** What a step's `TestStepInfo` can do at runtime: `step.skip()`. */
6
+ const STEP_INFO_METHODS = new Set(['skip']);
12
7
  const MARKER_LINE_RE = /^\s*\*?\s*([A-Za-z][\w-]*)\s*:(.*)$/;
13
8
  const TAG_RE = /(?<![\w@])@[\w-]+/g;
14
9
  export function isStateMarker(marker) {
15
10
  return marker.state !== undefined;
16
11
  }
12
+ /** The names a parameter gives to runtime info: `testInfo`, or `skip` in `({ skip }) => ...`. */
13
+ function infoNames(param, methods, step) {
14
+ if (param?.type === 'Identifier')
15
+ return [{ name: param.name, methods, step }];
16
+ if (param?.type !== 'ObjectPattern')
17
+ return [];
18
+ return param.properties.flatMap((prop) => {
19
+ if (prop.type !== 'Property' || prop.value.type !== 'Identifier')
20
+ return [];
21
+ const method = propertyName(prop);
22
+ return method !== undefined && methods.has(method) ? [{ name: prop.value.name, method, step }] : [];
23
+ });
24
+ }
17
25
  function memberName(node) {
18
26
  if (!node.computed && node.property.type === 'Identifier')
19
27
  return node.property.name;
@@ -21,17 +29,40 @@ function memberName(node) {
21
29
  return node.property.value;
22
30
  return undefined;
23
31
  }
24
- function chainOf(node) {
32
+ /**
33
+ * The name a callee starts from and the members after it: `['describe', 'skip']` for
34
+ * `test.describe.skip`. A member called to build the function, as `each` in `test.each(table)` or
35
+ * ``test.each`...` ``, is written with parentheses: `['skip', 'each()']` for `test.skip.each(table)`.
36
+ */
37
+ function chainOf(node, factories) {
25
38
  const path = [];
39
+ const args = new Map();
26
40
  let current = node;
27
- while (current.type === 'MemberExpression') {
28
- const name = memberName(current);
29
- if (name === undefined)
41
+ for (;;) {
42
+ if (current.type === 'MemberExpression') {
43
+ const name = memberName(current);
44
+ if (name === undefined)
45
+ return undefined;
46
+ path.unshift(name);
47
+ current = current.object;
48
+ continue;
49
+ }
50
+ const factory = current.type === 'CallExpression'
51
+ ? current.callee
52
+ : current.type === 'TaggedTemplateExpression'
53
+ ? current.tag
54
+ : undefined;
55
+ if (factory?.type !== 'MemberExpression')
56
+ break;
57
+ const name = memberName(factory);
58
+ if (name === undefined || !factories.has(name))
30
59
  return undefined;
31
- path.unshift(name);
32
- current = current.object;
60
+ path.unshift(`${name}()`);
61
+ if (current.type === 'CallExpression')
62
+ args.set(`${name}()`, current.arguments.at(0));
63
+ current = factory.object;
33
64
  }
34
- return current.type === 'Identifier' ? { root: current, path } : undefined;
65
+ return current.type === 'Identifier' ? { root: current, path, args } : undefined;
35
66
  }
36
67
  function unwrap(node) {
37
68
  let current = node;
@@ -45,52 +76,75 @@ function unwrap(node) {
45
76
  function isFunction(node) {
46
77
  return node?.type === 'ArrowFunctionExpression' || node?.type === 'FunctionExpression';
47
78
  }
48
- /** Collects the top-level names that refer to Playwright's `test`. */
49
- function collectTestNames(program, configured) {
50
- const names = new Set(configured);
79
+ /** Collects the top-level names that refer to the framework's test functions or to its module. */
80
+ function collectTestNames(program, framework, configured) {
81
+ const roots = new Map(framework.globals);
82
+ for (const name of configured)
83
+ roots.set(name, TEST);
84
+ const modules = new Set();
51
85
  const mergeTests = new Set();
52
86
  /** Names bound to another test runner, such as `ava` in `import ava from 'ava'`. */
53
87
  const others = new Set();
54
- const isTestExpression = (node) => {
88
+ /** The member name of `pw.test` or `pw.mergeTests` on a framework module. */
89
+ const moduleMember = (node) => node.type === 'MemberExpression' && node.object.type === 'Identifier' && modules.has(node.object.name)
90
+ ? memberName(node)
91
+ : undefined;
92
+ /** The test function an expression is, such as `base.extend({...})` or `mergeTests(a, b)`. */
93
+ const resolve = (node) => {
55
94
  const target = unwrap(node);
56
95
  if (target.type === 'Identifier')
57
- return names.has(target.name);
96
+ return roots.get(target.name);
97
+ const member = moduleMember(target);
98
+ if (member !== undefined)
99
+ return framework.exports.get(member);
58
100
  if (target.type !== 'CallExpression')
59
- return false;
60
- // mergeTests(dbTest, a11yTest)
101
+ return undefined;
102
+ // mergeTests(dbTest, a11yTest) or pw.mergeTests(dbTest, a11yTest)
61
103
  if (target.callee.type === 'Identifier')
62
- return mergeTests.has(target.callee.name);
104
+ return mergeTests.has(target.callee.name) ? TEST : undefined;
63
105
  if (target.callee.type !== 'MemberExpression')
64
- return false;
65
- return memberName(target.callee) === 'extend' && isTestExpression(target.callee.object);
106
+ return undefined;
107
+ if (moduleMember(target.callee) === 'mergeTests')
108
+ return TEST;
109
+ return memberName(target.callee) === 'extend' ? resolve(target.callee.object) : undefined;
66
110
  };
67
111
  // require('node:test'), ava, ava.serial or `ava as TestFn<Context>`
68
112
  const isOtherFramework = (node) => {
69
113
  const target = unwrap(node);
70
114
  const source = requireSource(target);
71
115
  if (source !== undefined)
72
- return OTHER_FRAMEWORKS.has(source);
116
+ return isOtherRunner(framework, source);
73
117
  if (target.type === 'Identifier')
74
118
  return others.has(target.name);
75
119
  return target.type === 'MemberExpression' && isOtherFramework(target.object);
76
120
  };
121
+ const setOther = (name) => {
122
+ roots.delete(name);
123
+ others.add(name);
124
+ };
77
125
  for (const statement of program.body) {
78
126
  if (statement.type === 'ImportDeclaration') {
79
127
  const source = statement.source.value;
80
- if (OTHER_FRAMEWORKS.has(source)) {
81
- for (const spec of statement.specifiers) {
82
- names.delete(spec.local.name);
83
- others.add(spec.local.name);
84
- }
128
+ if (isOtherRunner(framework, source)) {
129
+ for (const spec of statement.specifiers)
130
+ setOther(spec.local.name);
85
131
  }
86
- else if (isPlaywrightModule(source)) {
132
+ else if (framework.ownsModule(source)) {
87
133
  for (const spec of statement.specifiers) {
88
- if (spec.type === 'ImportDefaultSpecifier')
89
- names.add(spec.local.name);
90
- else if (spec.type === 'ImportSpecifier' && importedName(spec) === 'test')
91
- names.add(spec.local.name);
92
- else if (spec.type === 'ImportSpecifier' && importedName(spec) === 'mergeTests')
93
- mergeTests.add(spec.local.name);
134
+ const local = spec.local.name;
135
+ if (spec.type === 'ImportNamespaceSpecifier')
136
+ modules.add(local);
137
+ else if (spec.type === 'ImportDefaultSpecifier') {
138
+ if (framework.defaultExport)
139
+ roots.set(local, framework.defaultExport);
140
+ }
141
+ else {
142
+ const root = framework.exports.get(importedName(spec));
143
+ if (root)
144
+ roots.set(local, root);
145
+ else if (importedName(spec) === 'mergeTests')
146
+ mergeTests.add(local);
147
+ }
94
148
  }
95
149
  }
96
150
  continue;
@@ -102,32 +156,47 @@ function collectTestNames(program, configured) {
102
156
  const init = declarator.init && unwrap(declarator.init);
103
157
  if (!init)
104
158
  continue;
105
- if (declarator.id.type === 'Identifier' && init.type === 'CallExpression' && isTestExpression(init)) {
106
- names.add(declarator.id.name);
107
- }
108
- else if (declarator.id.type === 'Identifier' && isOtherFramework(init)) {
159
+ if (declarator.id.type === 'Identifier') {
160
+ const name = declarator.id.name;
161
+ // `const t = base.extend({...})`, `const t = mergeTests(a, b)` or a plain alias, `const t = base`.
162
+ const root = resolve(init);
163
+ if (root)
164
+ roots.set(name, root);
109
165
  // `const test = require('node:test')` is another runner's `test`, like an import from it.
110
- names.delete(declarator.id.name);
111
- others.add(declarator.id.name);
166
+ else if (isOtherFramework(init))
167
+ setOther(name);
168
+ else {
169
+ // `const pw = require('@playwright/test')`, used as `pw.test`.
170
+ const source = requireSource(init);
171
+ if (source !== undefined && framework.ownsModule(source))
172
+ modules.add(name);
173
+ }
112
174
  }
113
175
  else if (declarator.id.type === 'ObjectPattern') {
114
176
  const source = requireSource(init);
115
177
  if (source === undefined)
116
178
  continue;
117
179
  for (const prop of declarator.id.properties) {
118
- if (prop.type !== 'Property' || prop.key.type !== 'Identifier' || prop.value.type !== 'Identifier')
180
+ if (prop.type !== 'Property' || prop.value.type !== 'Identifier')
119
181
  continue;
120
- if (OTHER_FRAMEWORKS.has(source)) {
121
- names.delete(prop.value.name);
122
- others.add(prop.value.name);
182
+ if (isOtherRunner(framework, source))
183
+ setOther(prop.value.name);
184
+ else if (framework.ownsModule(source)) {
185
+ const root = framework.exports.get(propertyName(prop) ?? '');
186
+ if (root)
187
+ roots.set(prop.value.name, root);
123
188
  }
124
- else if (isPlaywrightModule(source) && prop.key.name === 'test')
125
- names.add(prop.value.name);
126
189
  }
127
190
  }
128
191
  }
129
192
  }
130
- return names;
193
+ return { roots, modules };
194
+ }
195
+ /** The name a property key spells out: `test` in `{ test }`, `{ 'test': t }` or `{ ['test']: t }`. */
196
+ function propertyName(prop) {
197
+ if (prop.key.type === 'Literal')
198
+ return typeof prop.key.value === 'string' ? prop.key.value : undefined;
199
+ return prop.computed ? undefined : prop.key.name;
131
200
  }
132
201
  function importedName(spec) {
133
202
  return spec.imported.type === 'Identifier' ? spec.imported.name : spec.imported.value;
@@ -148,7 +217,9 @@ function isLocalVariable(sourceCode, id) {
148
217
  const variable = scope.set.get(id.name);
149
218
  if (!variable)
150
219
  continue;
151
- if (scope.type === 'module' || scope.type === 'global')
220
+ // A top-level scope: the global scope, a module's scope, or in CommonJS the function scope that
221
+ // wraps the module.
222
+ if (scope.block.type === 'Program')
152
223
  return false;
153
224
  return variable.defs.some((def) => def.type === 'Variable');
154
225
  }
@@ -193,8 +264,11 @@ export function parseTickets(text, offset, matcher) {
193
264
  const token = /^[^\s,]+/.exec(text.slice(index))?.[0];
194
265
  if (!token)
195
266
  break;
196
- // Punctuation right after a ticket (`WEB-1:` or `WEB-1.`) is not part of it.
267
+ // Punctuation right after a ticket (`TRADE-1:` or `TRADE-1.`) is not part of it.
197
268
  const ticket = token.replace(/[.:;]+$/, '');
269
+ // Punctuation alone, as in `// SKIP: .`, is no ticket at all.
270
+ if (ticket === '')
271
+ break;
198
272
  tickets.push({ text: ticket, result: matcher.check(ticket) });
199
273
  index += ticket.length;
200
274
  lastEnd = index;
@@ -204,75 +278,228 @@ export function parseTickets(text, offset, matcher) {
204
278
  index += separator.length;
205
279
  }
206
280
  const rest = text.slice(lastEnd).trimEnd();
207
- // A sentence-ending `WEB-1.` has nothing after the ticket; `WEB-1: flaky` has a note.
281
+ // A sentence-ending `TRADE-1.` has nothing after the ticket; `TRADE-1: flaky` has a note.
208
282
  if (tickets.length === 0 || /^[.:;]*$/.test(rest.trim()))
209
283
  return { tickets };
210
284
  return { tickets, extra: { text: rest.trim(), range: [offset + lastEnd, offset + lastEnd + rest.length] } };
211
285
  }
286
+ const LINE_BREAK_RE = /\r\n|[\r\n\u2028\u2029]/g;
287
+ /** The lines of a comment and where each starts in the source, split at every line break JavaScript has. */
288
+ export function commentLines(comment) {
289
+ const lines = [];
290
+ // `//` and `/*` are both two characters, so the comment's value starts two characters in.
291
+ const valueStart = comment.range[0] + 2;
292
+ let lineStart = 0;
293
+ for (const lineBreak of comment.value.matchAll(LINE_BREAK_RE)) {
294
+ lines.push({ text: comment.value.slice(lineStart, lineBreak.index), start: valueStart + lineStart });
295
+ lineStart = lineBreak.index + lineBreak[0].length;
296
+ }
297
+ lines.push({ text: comment.value.slice(lineStart), start: valueStart + lineStart });
298
+ return lines;
299
+ }
212
300
  function parseMarkers(comment, states) {
213
301
  const markers = [];
214
- // `//` and `/*` are both two characters, so the comment's value starts two characters in.
215
- let lineStart = comment.range[0] + 2;
216
- for (const line of comment.value.split(/\n/)) {
217
- const match = MARKER_LINE_RE.exec(line.replace(/\r$/, ''));
218
- const start = lineStart;
219
- lineStart += line.length + 1;
302
+ for (const { text, start } of commentLines(comment)) {
303
+ const match = MARKER_LINE_RE.exec(text);
220
304
  if (!match)
221
305
  continue;
222
306
  const [, keyword, rest] = match;
307
+ const restOffset = start + match[0].length - rest.length;
223
308
  const state = states.find((s) => s.marker === keyword);
224
309
  if (state) {
225
- const restOffset = start + match[0].length - rest.length;
226
310
  markers.push({ comment, keyword, state, ...parseTickets(rest, restOffset, state.ticket) });
227
311
  continue;
228
312
  }
229
313
  const caseOf = states.find((s) => s.marker === keyword.toUpperCase());
230
314
  if (caseOf)
231
- markers.push({ comment, keyword, caseOf, tickets: [] });
315
+ markers.push({ comment, keyword, caseOf, ...parseTickets(rest, restOffset, caseOf.ticket) });
232
316
  }
233
317
  return markers;
234
318
  }
235
- function scanTags(node, out) {
236
- const texts = node.type === 'Literal'
237
- ? [String(node.value)]
238
- : // `cooked` is only null in tagged templates, which are never titles.
319
+ function scanTags(source, { text: node, via }, out) {
320
+ // Each piece of text with where it starts in the source, after its opening quote, backtick or `}`.
321
+ const parts = node.type === 'Literal'
322
+ ? [{ text: node.value, start: node.range[0] + 1 }]
323
+ : node.quasis.map((quasi) => ({
324
+ // `cooked` is only null in tagged templates, which are never titles.
239
325
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- see above
240
- node.quasis.map((quasi) => quasi.value.cooked);
241
- for (const text of texts) {
242
- for (const match of text.matchAll(TAG_RE))
243
- out.push({ tag: match[0], node });
326
+ text: quasi.value.cooked,
327
+ start: quasi.range[0] + 1,
328
+ }));
329
+ for (const { text, start } of parts) {
330
+ for (const match of text.matchAll(TAG_RE)) {
331
+ const end = match.index + match[0].length;
332
+ const written = via === undefined && source.slice(start, start + end) === text.slice(0, end);
333
+ out.push({ tag: match[0], node: via ?? node, ...(written && { range: [start + match.index, start + end] }) });
334
+ }
244
335
  }
245
336
  }
337
+ const PLAIN_TAG_RE = /^[\w-]+$/;
338
+ /** A Vitest tag name such as `'flaky'` in `tags`, which stands for the `@flaky` tag. */
339
+ function plainTag(source, { text, via }) {
340
+ if (text.type !== 'Literal' || !PLAIN_TAG_RE.test(text.value))
341
+ return undefined;
342
+ const start = text.range[0] + 1;
343
+ const end = start + text.value.length;
344
+ const written = via === undefined && source.slice(start, end) === text.value;
345
+ return { tag: `@${text.value}`, node: via ?? text, plain: true, ...(written && { range: [start, end] }) };
346
+ }
246
347
  function isStaticText(node) {
247
348
  return (node.type === 'Literal' && typeof node.value === 'string') || node.type === 'TemplateLiteral';
248
349
  }
249
- function collectTags(call, hasTitle) {
250
- const tags = [];
251
- if (!hasTitle)
252
- return { tags, dynamic: false };
253
- const [title, details] = call.arguments;
254
- const dynamic = !isStaticText(title);
255
- if (!dynamic)
256
- scanTags(title, tags);
257
- if (call.arguments.length >= 3 && details.type === 'ObjectExpression') {
258
- for (const prop of details.properties) {
259
- if (prop.type !== 'Property' || prop.computed)
260
- continue;
261
- const key = prop.key.type === 'Identifier' ? prop.key.name : String(prop.key.value);
262
- if (key !== 'tag')
263
- continue;
264
- const values = prop.value.type === 'ArrayExpression' ? prop.value.elements : [prop.value];
265
- for (const value of values) {
266
- if (value && isStaticText(value))
267
- scanTags(value, tags);
268
- }
350
+ /**
351
+ * The value a `const` or enum declared in this file gives a name: the `'@new'` of `const NEW = '@new'`,
352
+ * or the enum itself. Undefined for any other name, such as an import, a parameter or a `let`.
353
+ */
354
+ function declaredValue(sourceCode, id) {
355
+ for (let scope = sourceCode.getScope(id); scope; scope = scope.upper) {
356
+ const variable = scope.set.get(id.name);
357
+ if (!variable)
358
+ continue;
359
+ // A name declared more than once, as a merged enum, has no single value.
360
+ if (variable.defs.length !== 1)
361
+ return undefined;
362
+ const [def] = variable.defs;
363
+ if (def.type === 'TSEnumName')
364
+ return def.node;
365
+ const declarator = def.type === 'Variable' && def.parent.kind === 'const' ? def.node : undefined;
366
+ return declarator?.id.type === 'Identifier' ? (declarator.init ?? undefined) : undefined;
367
+ }
368
+ return undefined;
369
+ }
370
+ /** The value of the last property called `key`, or undefined when a spread written after it may replace it. */
371
+ function propertyValue(object, key) {
372
+ for (let i = object.properties.length - 1; i >= 0; i--) {
373
+ const prop = object.properties[i];
374
+ if (prop.type === 'SpreadElement')
375
+ return undefined;
376
+ if (propertyName(prop) === key)
377
+ return prop.value;
378
+ }
379
+ return undefined;
380
+ }
381
+ /**
382
+ * What a name or member stands for when it is a constant declared in this file: the `'@new'` of `NEW`
383
+ * after `const NEW = '@new'`, or of `Tags.NEW` after `const Tags = { NEW: '@new' }` or
384
+ * `enum Tags { NEW = '@new' }`.
385
+ */
386
+ function constantValue(sourceCode, node) {
387
+ if (node.type === 'Identifier')
388
+ return declaredValue(sourceCode, node);
389
+ if (node.type !== 'MemberExpression')
390
+ return undefined;
391
+ const key = memberName(node);
392
+ const value = constantValue(sourceCode, unwrap(node.object));
393
+ const owner = value && unwrap(value);
394
+ if (key === undefined || owner === undefined)
395
+ return undefined;
396
+ if (owner.type === 'ObjectExpression')
397
+ return propertyValue(owner, key);
398
+ if (owner.type !== 'TSEnumDeclaration')
399
+ return undefined;
400
+ const member = owner.body.members.find((m) => (m.id.type === 'Identifier' ? m.id.name : m.id.value) === key);
401
+ return member?.initializer;
402
+ }
403
+ /**
404
+ * Reads the text a title or tag value is made of: strings, template literals and arrays of them,
405
+ * following constants declared in this file. What can't be read, such as a name imported from another
406
+ * file, goes in `unread`: the name the call uses, or the value itself.
407
+ */
408
+ function readTexts(sourceCode, node, out, via, path = []) {
409
+ const target = unwrap(node);
410
+ if (isStaticText(target)) {
411
+ out.texts.push({ text: target, via });
412
+ return;
413
+ }
414
+ if (target.type === 'ArrayExpression') {
415
+ for (const item of target.elements) {
416
+ if (item)
417
+ readTexts(sourceCode, item.type === 'SpreadElement' ? item.argument : item, out, via, path);
269
418
  }
419
+ return;
270
420
  }
271
- return { tags, dynamic };
421
+ const value = constantValue(sourceCode, target);
422
+ // `path` holds the constants already followed, so `const a = b; const b = a;` ends.
423
+ if (value === undefined || path.includes(value))
424
+ out.unread.add(via ?? target);
425
+ else
426
+ readTexts(sourceCode, value, out, via ?? target, [...path, value]);
427
+ }
428
+ /**
429
+ * The details or options object of a declaration, the second argument in
430
+ * `test('title', { tag: '@smoke' }, fn)` or Vitest's `test('title', { skip: true }, fn)`, also when it
431
+ * is a constant declared in this file.
432
+ */
433
+ function detailsOf(sourceCode, call) {
434
+ const details = call.arguments.at(1);
435
+ if (details === undefined || isFunction(details))
436
+ return { entries: [] };
437
+ const target = unwrap(details);
438
+ const value = target.type === 'ObjectExpression' ? target : constantValue(sourceCode, target);
439
+ const object = value && unwrap(value);
440
+ if (object?.type !== 'ObjectExpression') {
441
+ // A name that can't be read is the details object only when a body comes after it:
442
+ // `test.skip('places an order', placeOrder)` has a body defined elsewhere and no details.
443
+ return call.arguments.slice(2).some(isFunction) ? { entries: [], unread: details } : { entries: [] };
444
+ }
445
+ const entries = object.properties.flatMap((prop) => {
446
+ if (prop.type !== 'Property' || prop.computed)
447
+ return [];
448
+ const key = prop.key.type === 'Identifier' ? prop.key.name : String(prop.key.value);
449
+ return [[key, prop.value]];
450
+ });
451
+ return { entries };
452
+ }
453
+ const NO_TAGS = { tags: [], dynamic: false, unread: [], opaqueDetails: false };
454
+ function collectTags(sourceCode, call, hasTitle, framework, details) {
455
+ if (!hasTitle)
456
+ return NO_TAGS;
457
+ const source = sourceCode.text;
458
+ const tags = [];
459
+ const title = { texts: [], unread: new Set() };
460
+ readTexts(sourceCode, call.arguments[0], title);
461
+ for (const found of title.texts)
462
+ scanTags(source, found, tags);
463
+ const values = { texts: [], unread: new Set() };
464
+ for (const [key, value] of details.entries) {
465
+ if (key === framework.tagKey)
466
+ readTexts(sourceCode, value, values);
467
+ }
468
+ for (const found of values.texts) {
469
+ const plain = framework.plainTags ? plainTag(source, found) : undefined;
470
+ if (plain)
471
+ tags.push(plain);
472
+ else
473
+ scanTags(source, found, tags);
474
+ }
475
+ const unread = [...values.unread];
476
+ if (details.unread && framework.tagKey !== undefined)
477
+ unread.push(details.unread);
478
+ return { tags, dynamic: title.unread.size > 0, unread, opaqueDetails: details.unread !== undefined };
479
+ }
480
+ /**
481
+ * Whether a call declares a test or describe block: a title and a body, as in `test('title', fn)` or
482
+ * `test('title', details, fn)`, a static title with a body defined elsewhere, as in
483
+ * `test.skip('pays', payWithCard)`, a describe with only a body, or a `todo` with only a title. A string
484
+ * title tells `test.skip('pays', payWithCard)` apart from a runtime `test.skip(isMobile, 'why')`.
485
+ */
486
+ function isDeclaration(kind, args, todo) {
487
+ const first = args.at(0);
488
+ if (isFunction(first))
489
+ return kind === 'describe';
490
+ if (first === undefined)
491
+ return false;
492
+ if (args.length === 1)
493
+ return todo;
494
+ return isStaticText(first) || args.slice(1).some(isFunction);
495
+ }
496
+ /** The value of a `true` or `false` literal; undefined for anything else. */
497
+ function booleanOf(node) {
498
+ return node?.type === 'Literal' && typeof node.value === 'boolean' ? node.value : undefined;
272
499
  }
273
500
  function isUnconditional(call) {
274
501
  const first = call.arguments.at(0);
275
- return (first === undefined || (first.type === 'Literal' && first.value === true)) && !isGuarded(call);
502
+ return (first === undefined || booleanOf(first) === true) && !isGuarded(call);
276
503
  }
277
504
  const FUNCTIONS = new Set(['FunctionDeclaration', 'FunctionExpression', 'ArrowFunctionExpression']);
278
505
  /** Whether a statement always leaves the function or block: `return`, `throw`, or a block containing one. */
@@ -311,6 +538,18 @@ function isGuarded(call) {
311
538
  }
312
539
  return false;
313
540
  }
541
+ /** Keys that point back up the tree or at comments rather than at child nodes. */
542
+ const NON_CHILD_KEYS = new Set(['parent', 'leadingComments', 'trailingComments']);
543
+ /**
544
+ * The keys of a node type that the parser gave no visitor keys for, read from the node itself, as
545
+ * ESLint's own traverser does. Without this, tests inside such a node would go unchecked.
546
+ */
547
+ function ownKeys(node) {
548
+ return Object.keys(node).filter((key) => !NON_CHILD_KEYS.has(key) && !key.startsWith('_'));
549
+ }
550
+ function isNode(value) {
551
+ return typeof value?.type === 'string';
552
+ }
314
553
  const cache = new WeakMap();
315
554
  export function analyze(sourceCode, options) {
316
555
  let byOptions = cache.get(sourceCode);
@@ -326,19 +565,41 @@ export function analyze(sourceCode, options) {
326
565
  return analysis;
327
566
  }
328
567
  function runAnalysis(sourceCode, options) {
329
- const { states } = options;
330
- const testNames = collectTestNames(sourceCode.ast, options.testFunctions);
331
- let usesTest = sourceCode.ast.body.some((statement) => statement.type === 'ImportDeclaration' && isPlaywrightModule(statement.source.value));
568
+ const { states, framework } = options;
569
+ const testNames = collectTestNames(sourceCode.ast, framework, options.testFunctions);
570
+ /**
571
+ * The test function a callee starts from and the members after it, such as `test` and
572
+ * `['describe', 'skip']` for `test.describe.skip` or `pw.test.describe.skip`. Undefined when the callee
573
+ * isn't one of the framework's test functions.
574
+ */
575
+ const target = (chain) => {
576
+ if (chain === undefined)
577
+ return undefined;
578
+ const { root, path, args } = chain;
579
+ let base = testNames.roots.get(root.name);
580
+ let rest = path;
581
+ if (base === undefined && testNames.modules.has(root.name)) {
582
+ base = framework.exports.get(path[0]);
583
+ rest = path.slice(1);
584
+ }
585
+ return base !== undefined && !isLocalVariable(sourceCode, root) ? { root: base, path: rest, args } : undefined;
586
+ };
587
+ let usesTest = sourceCode.ast.body.some((statement) => statement.type === 'ImportDeclaration' && framework.ownsModule(statement.source.value));
332
588
  const subjects = [];
333
589
  const claimed = new Set();
334
590
  const stack = [];
335
- const testInfoNames = [];
591
+ const infos = [];
336
592
  const keys = sourceCode.visitorKeys;
337
- const makeSubject = (kind, call, modifiers, tagInfo, required = true) => {
338
- const parent = stack.at(-1);
593
+ /** States an options object can put a test in, such as `skip` for Vitest's `{ skip: true }`. */
594
+ const optionModifiers = new Set(framework.optionEffects.values());
595
+ /**
596
+ * `modifiers` maps each state modifier the call has to whether it always applies; a conditional one,
597
+ * like `test.skip(isMobile)` or Vitest's `skipIf(...)`, needs a ticket only with `requireTicketForConditional`.
598
+ */
599
+ const makeSubject = (kind, call, modifiers, tagInfo, parent = stack.at(-1)) => {
339
600
  const anchor = anchorOf(call);
340
601
  const block = commentBlock(sourceCode, anchor, options.allowBlankLine);
341
- // `rows.forEach((row) =>\n // SKIP: WEB-1\n test.skip(...))`: the marker sits above the call itself.
602
+ // `symbols.forEach((symbol) =>\n // SKIP: TRADE-1\n test.skip(...))`: the marker sits above the call itself.
342
603
  if (call.parent.type === 'ArrowFunctionExpression' && call.parent.body === call) {
343
604
  block.push(...commentBlock(sourceCode, call, options.allowBlankLine));
344
605
  }
@@ -347,23 +608,41 @@ function runAnalysis(sourceCode, options) {
347
608
  const ownTags = new Set(tagInfo.tags.map((t) => t.tag));
348
609
  const sources = [];
349
610
  for (const state of states) {
350
- const matches = state.modifier !== undefined ? modifiers.includes(state.modifier) : ownTags.has(state.tag);
351
- if (matches)
352
- sources.push({ state, required });
611
+ if (state.modifier === undefined) {
612
+ if (ownTags.has(state.tag))
613
+ sources.push({ state, required: true });
614
+ continue;
615
+ }
616
+ const always = modifiers.get(state.modifier);
617
+ if (always !== undefined)
618
+ sources.push({ state, required: always || options.requireTicketForConditional });
353
619
  }
354
620
  const inherited = new Set();
355
621
  const inheritedTags = new Set();
622
+ const unknownStates = new Set();
356
623
  if (parent && kind !== 'runtime') {
357
624
  for (const name of parent.inherited)
358
625
  inherited.add(name);
359
626
  for (const source of parent.states)
360
627
  inherited.add(source.state.name);
628
+ for (const name of parent.unknownStates)
629
+ unknownStates.add(name);
630
+ }
631
+ for (const state of states) {
632
+ const unknown = state.modifier === undefined
633
+ ? tagInfo.unread.length > 0
634
+ : tagInfo.opaqueDetails && optionModifiers.has(state.modifier);
635
+ if (unknown)
636
+ unknownStates.add(state.name);
637
+ }
638
+ // Tags belong to tests: a step in a `@new` test is not itself new.
639
+ if (parent && (kind === 'test' || kind === 'describe')) {
361
640
  for (const tag of parent.inheritedTags)
362
641
  inheritedTags.add(tag);
363
642
  for (const tag of parent.tags)
364
643
  inheritedTags.add(tag.tag);
365
644
  }
366
- const ownSkip = modifiers.some((m) => SKIPPING_MODIFIERS.has(m));
645
+ const ownSkip = [...modifiers].some(([modifier, always]) => always && SKIPPING_MODIFIERS.has(modifier));
367
646
  const subject = {
368
647
  kind,
369
648
  node: call,
@@ -374,6 +653,8 @@ function runAnalysis(sourceCode, options) {
374
653
  runtimeStates: new Set(),
375
654
  tags: tagInfo.tags,
376
655
  inheritedTags,
656
+ unreadTags: tagInfo.unread,
657
+ unknownStates,
377
658
  skipped: ownSkip || (kind !== 'runtime' && parent?.skipped === true),
378
659
  ownSkip,
379
660
  markers: block.flatMap((comment) => parseMarkers(comment, states)),
@@ -382,60 +663,122 @@ function runAnalysis(sourceCode, options) {
382
663
  subjects.push(subject);
383
664
  return subject;
384
665
  };
666
+ /**
667
+ * The state modifiers of a declaration, from its members and, in Vitest, its options object. `args`
668
+ * holds the conditions of members such as `skipIf()`.
669
+ */
670
+ const modifiersOf = (members, details, args) => {
671
+ const modifiers = new Map();
672
+ const add = (modifier, always) => {
673
+ if (!modifiers.get(modifier))
674
+ modifiers.set(modifier, always);
675
+ };
676
+ for (const member of members) {
677
+ const effect = framework.effects.get(member);
678
+ if (!effect)
679
+ continue;
680
+ if (effect.when === undefined) {
681
+ add(effect.modifier, true);
682
+ continue;
683
+ }
684
+ // `skipIf(true)` always skips and `skipIf(false)` never does, like `{ skip: true }` and `{ skip: false }`.
685
+ const condition = booleanOf(args.get(member));
686
+ if (condition === undefined)
687
+ add(effect.modifier, false);
688
+ else if (condition === effect.when)
689
+ add(effect.modifier, true);
690
+ }
691
+ // `{ skip: true }` always skips, `{ skip: isMobile }` only sometimes, `{ skip: false }` never.
692
+ for (const [key, value] of details) {
693
+ const modifier = framework.optionEffects.get(key);
694
+ const literal = booleanOf(value);
695
+ if (modifier && literal !== false)
696
+ add(modifier, literal === true);
697
+ }
698
+ return modifiers;
699
+ };
700
+ /** What a body can change the test's state with: Playwright's `testInfo` or Vitest's test context. */
701
+ const bodyInfos = (args, path) => {
702
+ const body = args.findLast(isFunction);
703
+ // `test.each(table)` passes the row to the body, and `test.for(cases)` passes it before the context.
704
+ if (!framework.info || !body || path.includes('each()'))
705
+ return [];
706
+ const param = body.params.at(framework.info.param + (path.includes('for()') ? 1 : 0));
707
+ return infoNames(param, framework.info.methods);
708
+ };
385
709
  const visitCall = (call) => {
386
- const chain = chainOf(call.callee);
710
+ const callee = target(chainOf(call.callee, framework.factories));
711
+ if (callee === undefined)
712
+ return { subject: runtimeCall(call) };
713
+ usesTest = true;
387
714
  const args = call.arguments;
388
- const last = args.at(-1);
389
- let testInfo;
390
- if (chain && testNames.has(chain.root.name) && !isLocalVariable(sourceCode, chain.root)) {
391
- usesTest = true;
392
- const { path } = chain;
393
- if (isFunction(last)) {
394
- const param = last.params.at(1);
395
- if (param?.type === 'Identifier')
396
- testInfo = param.name;
397
- }
398
- // The body is usually written inline, but can be a function defined elsewhere:
399
- // `test.skip('pays', payWithCard)`. A string title tells that apart from `test.skip(cond, 'why')`.
400
- const titled = args.length >= 2 && isStaticText(args[0]);
401
- const isDeclaration = args.length >= 2 && !isFunction(args[0]) && (isFunction(last) || titled);
402
- if (path.every((p) => TEST_MODIFIERS.has(p)) && isDeclaration) {
403
- return { subject: makeSubject('test', call, path, collectTags(call, true)), testInfo };
404
- }
405
- if (path[0] === 'describe' &&
406
- path.slice(1).every((p) => DESCRIBE_MODIFIERS.has(p)) &&
407
- (isFunction(last) || titled)) {
408
- const tagInfo = collectTags(call, args.length >= 2);
409
- return { subject: makeSubject('describe', call, path.slice(1), tagInfo), testInfo };
410
- }
411
- if (path.length === 1 && RUNTIME_MODIFIERS.has(path[0])) {
412
- return { subject: runtimeSubject(call, path[0]), testInfo };
715
+ const { root } = callee;
716
+ let { path } = callee;
717
+ // Vitest's `beforeEach((context) => context.skip())` skips the tests it runs before.
718
+ if (root.kind === 'hook')
719
+ return { infos: bodyInfos(args, path) };
720
+ if (framework.playwright) {
721
+ // `test.step('fills the order', async (step) => {...})` or `test.step.skip(...)`. The step's body
722
+ // gets a `TestStepInfo` that can skip the step at runtime.
723
+ const step = path.join('.');
724
+ if ((step === 'step' || step === 'step.skip') && args.length >= 2) {
725
+ const subject = makeSubject('step', call, modifiersOf(path.slice(1), [], callee.args), NO_TAGS);
726
+ const body = args[1];
727
+ const param = isFunction(body) ? body.params.at(0) : undefined;
728
+ return { subject, infos: infoNames(param, STEP_INFO_METHODS, subject) };
413
729
  }
414
- return { testInfo };
415
730
  }
416
- // testInfo.skip() and test.info().skip()
417
- if (call.callee.type === 'MemberExpression') {
418
- const name = memberName(call.callee);
419
- const object = call.callee.object;
420
- if (name !== undefined && RUNTIME_MODIFIERS.has(name)) {
421
- const isTestInfo = (object.type === 'Identifier' && testInfoNames.includes(object.name)) ||
422
- (object.type === 'CallExpression' &&
423
- (() => {
424
- const inner = chainOf(object.callee);
425
- return inner !== undefined && testNames.has(inner.root.name) && inner.path.join('.') === 'info';
426
- })());
427
- if (isTestInfo)
428
- return { subject: runtimeSubject(call, name) };
429
- }
731
+ const bodyInfo = bodyInfos(args, path);
732
+ let { kind } = root;
733
+ if (framework.playwright && path[0] === 'describe') {
734
+ kind = 'describe';
735
+ path = path.slice(1);
736
+ }
737
+ const members = [...root.modifiers, ...path];
738
+ const allowed = kind === 'test' ? framework.testMembers : framework.describeMembers;
739
+ if (members.every((m) => allowed.has(m)) && isDeclaration(kind, args, members.includes('todo'))) {
740
+ // A declaration always has a first argument: its title, or the body of a describe without one.
741
+ const details = detailsOf(sourceCode, call);
742
+ const tagInfo = collectTags(sourceCode, call, !isFunction(args[0]), framework, details);
743
+ return {
744
+ subject: makeSubject(kind, call, modifiersOf(members, details.entries, callee.args), tagInfo),
745
+ infos: bodyInfo,
746
+ };
747
+ }
748
+ // test.skip(), test.fixme(), test.fail() and test.slow() in a test, a describe or a hook.
749
+ if (framework.playwright && path.length === 1 && RUNTIME_MODIFIERS.has(path[0])) {
750
+ return { subject: runtimeSubject(call, path[0]), infos: bodyInfo };
751
+ }
752
+ return { infos: bodyInfo };
753
+ };
754
+ /** `testInfo.skip()`, `step.skip()`, `test.info().skip()`, and Vitest's `context.skip()` or `skip()`. */
755
+ const runtimeCall = (call) => {
756
+ const { callee } = call;
757
+ // The innermost parameter with a name is the one the call uses.
758
+ const innermost = (name) => infos.findLast((info) => info.name === name);
759
+ if (callee.type === 'Identifier') {
760
+ const info = innermost(callee.name);
761
+ return info?.method !== undefined ? runtimeSubject(call, info.method, info.step) : undefined;
762
+ }
763
+ if (callee.type !== 'MemberExpression')
764
+ return undefined;
765
+ const name = memberName(callee);
766
+ if (name === undefined || !RUNTIME_MODIFIERS.has(name))
767
+ return undefined;
768
+ const { object } = callee;
769
+ if (object.type === 'Identifier') {
770
+ const info = innermost(object.name);
771
+ return info?.methods?.has(name) ? runtimeSubject(call, name, info.step) : undefined;
430
772
  }
431
- return {};
773
+ const isTestInfo = object.type === 'CallExpression' &&
774
+ target(chainOf(object.callee, framework.factories))?.path.join('.') === 'info';
775
+ return isTestInfo ? runtimeSubject(call, name) : undefined;
432
776
  };
433
- const runtimeSubject = (call, modifier) => {
777
+ /** `step` is set for `step.skip()`, which skips only its step; the other calls act on the whole test. */
778
+ const runtimeSubject = (call, modifier, step) => {
434
779
  if (!states.some((s) => s.modifier === modifier))
435
780
  return undefined;
436
- const unconditional = isUnconditional(call);
437
- const subject = makeSubject('runtime', call, [modifier], { tags: [], dynamic: false }, unconditional || options.requireTicketForConditional);
438
- subject.skipped = unconditional && SKIPPING_MODIFIERS.has(modifier);
781
+ const subject = makeSubject('runtime', call, new Map([[modifier, isUnconditional(call)]]), NO_TAGS, step ?? stack.findLast((s) => s.kind !== 'step'));
439
782
  const parent = subject.parent;
440
783
  if (parent) {
441
784
  parent.runtimeStates.add(subject.states[0].state.name);
@@ -446,35 +789,27 @@ function runAnalysis(sourceCode, options) {
446
789
  };
447
790
  const walk = (node) => {
448
791
  let pushedSubject = false;
449
- let pushedInfo = false;
792
+ let pushedInfos = 0;
450
793
  if (node.type === 'CallExpression') {
451
- const { subject, testInfo } = visitCall(node);
452
- if (subject && subject.kind !== 'runtime') {
453
- stack.push(subject);
794
+ const visit = visitCall(node);
795
+ if (visit.subject && visit.subject.kind !== 'runtime') {
796
+ stack.push(visit.subject);
454
797
  pushedSubject = true;
455
798
  }
456
- if (testInfo !== undefined) {
457
- testInfoNames.push(testInfo);
458
- pushedInfo = true;
799
+ for (const info of visit.infos ?? []) {
800
+ infos.push(info);
801
+ pushedInfos++;
459
802
  }
460
803
  }
461
- // Parsers provide visitor keys for every node type they produce; the fallback is only defensive.
462
- /* node:coverage ignore next */
463
- for (const key of keys[node.type] ?? []) {
804
+ for (const key of keys[node.type] ?? ownKeys(node)) {
464
805
  const child = node[key];
465
- if (Array.isArray(child)) {
466
- for (const item of child)
467
- if (item)
468
- walk(item);
469
- }
470
- else if (child && typeof child.type === 'string') {
471
- walk(child);
472
- }
806
+ for (const item of Array.isArray(child) ? child : [child])
807
+ if (isNode(item))
808
+ walk(item);
473
809
  }
474
810
  if (pushedSubject)
475
811
  stack.pop();
476
- if (pushedInfo)
477
- testInfoNames.pop();
812
+ infos.splice(infos.length - pushedInfos, pushedInfos);
478
813
  };
479
814
  walk(sourceCode.ast);
480
815
  const detachedMarkers = sourceCode
@@ -511,7 +846,7 @@ export function evaluate(subject, state) {
511
846
  }
512
847
  const isValid = (m) => m.tickets.length > 0 && m.tickets.every((t) => t.result === 'ok');
513
848
  // A broken marker in the subject's own block is reported even when another marker is valid: in
514
- // `// SKIP: WEB-1` + `// SKIP: nope`, the second line is still wrong. Broken markers further up
849
+ // `// SKIP: TRADE-1` + `// SKIP: nope`, the second line is still wrong. Broken markers further up
515
850
  // are reported for the test or describe they sit above.
516
851
  const brokenOwn = markers.find((m) => subject.markers.includes(m) && !isValid(m));
517
852
  if (!brokenOwn && markers.some(isValid))
@@ -538,32 +873,42 @@ export function isProse(marker) {
538
873
  * is also a work-comment keyword and it doesn't start with a valid ticket. `require-ticket-in-comments`
539
874
  * reports those; the marker rules leave them alone.
540
875
  */
541
- export function isWorkComment(marker, options) {
876
+ function isWorkComment(marker, options) {
542
877
  return options.workCommentKeywords.has(marker.keyword.toUpperCase()) && marker.tickets.at(0)?.result !== 'ok';
543
878
  }
544
- /** Markers in the subject's own block for states that don't apply to it, leaving out work comments. */
879
+ /**
880
+ * Markers in the subject's own block for states that don't apply to it, leaving out work comments and
881
+ * states its code may hide, such as a tag from a constant imported from another file. A marker in the
882
+ * wrong case, as `// skip: TRADE-1`, counts when it starts with a valid ticket.
883
+ */
545
884
  export function strayMarkers(subject, options) {
546
- return subject.markers
547
- .filter(isStateMarker)
548
- .filter((m) => !appliesTo(subject, m.state.name) && !isWorkComment(m, options));
885
+ return subject.markers.flatMap((marker) => {
886
+ const state = marker.state ?? (marker.tickets.at(0)?.result === 'ok' ? marker.caseOf : undefined);
887
+ if (state === undefined || appliesTo(subject, state.name) || subject.unknownStates.has(state.name))
888
+ return [];
889
+ return isWorkComment(marker, options) ? [] : [{ ...marker, state }];
890
+ });
549
891
  }
550
892
  /**
551
893
  * Where to report a problem with a test or describe: from the callee to the end of the title
552
- * (`test.skip('pays with PayPal'`), so editors underline the declaration rather than the whole body.
894
+ * (`test.skip('places a limit order'`), so editors underline the declaration rather than the whole body.
553
895
  * Runtime calls such as `test.skip()` are short, so they are reported whole.
554
896
  */
555
897
  export function headLoc(subject) {
556
898
  const { node } = subject;
557
899
  if (subject.kind === 'runtime')
558
900
  return node.loc;
559
- const title = node.arguments.length > 1 ? node.arguments[0] : undefined;
901
+ // A describe can have a body and no title. A todo test has only a title.
902
+ const [first] = node.arguments;
903
+ const title = isFunction(first) ? undefined : first;
560
904
  return { start: node.callee.loc.start, end: (title ?? node.callee).loc.end };
561
905
  }
562
906
  export function describeSubject(subject) {
563
907
  if (subject.kind === 'describe')
564
908
  return 'This describe block';
909
+ if (subject.kind === 'step')
910
+ return 'This step';
565
911
  if (subject.kind === 'runtime')
566
912
  return `This ${subject.states[0].state.modifier} call`;
567
913
  return 'This test';
568
914
  }
569
- //# sourceMappingURL=analyze.js.map