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
17 changes: 10 additions & 7 deletions scripts/chain-permutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,31 @@ const data = [
{
names: ['beforeEach', 'beforeAll', 'afterEach', 'afterAll'],
first: [],
exclusive: [],
conditions: [],
methods: [],
last: [],
},
{
names: ['it', 'test'],
first: ['extend'],
first: [],
exclusive: ['extend', 'scoped'],
conditions: ['skipIf', 'runIf'],
methods: ['skip', 'only', 'concurrent', 'sequential', 'todo', 'fails'],
last: ['each', 'for'],
},
{
names: ['bench'],
first: [],
exclusive: [],
conditions: ['skipIf', 'runIf'],
methods: ['skip', 'only', 'todo'],
last: [],
},
{
names: ['describe', 'suite'],
first: [],
exclusive: [],
conditions: ['skipIf', 'runIf'],
methods: ['skip', 'only', 'concurrent', 'sequential', 'shuffle', 'todo'],
last: ['each', 'for'],
Expand All @@ -43,15 +47,15 @@ const DEPTH = 3

const allPermutations: string[] = []

const depths = (maxDepth: number) =>
Array.from({ length: maxDepth }, (_, i) => i)

data.forEach((q) => {
q.names.forEach((name) => {
allPermutations.push(name)

allPermutations.push(...q.exclusive.map((p) => [name, p].join('.')))

const maxDepth = Math.min(DEPTH, q.methods.length)
const methodPerms = depths(maxDepth).flatMap((i) => [
const depths = Array.from({ length: maxDepth }, (_, i) => i)
const methodPerms = depths.flatMap((i) => [
...per(q.methods, i + 1),
...q.first.flatMap((first) =>
(per(q.methods, i) || ['']).map((p) => [first, ...p]),
Expand Down Expand Up @@ -106,8 +110,7 @@ data.forEach((q) => {
)
: []),
])
const allPerms = methodPerms.map((p) => [name, ...p].join('.'))
allPermutations.push(...allPerms)
allPermutations.push(...methodPerms.map((p) => [name, ...p].join('.')))
})
})

Expand Down
142 changes: 4 additions & 138 deletions src/utils/valid-vitest-fn-call-chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ export const ValidVitestFnCallChains = new Set([
'afterEach',
'afterAll',
'it',
'it.extend',
'it.scoped',
'it.skip',
'it.only',
'it.concurrent',
'it.sequential',
'it.todo',
'it.fails',
'it.extend',
'it.skipIf',
'it.runIf',
'it.each',
Expand Down Expand Up @@ -45,12 +46,6 @@ export const ValidVitestFnCallChains = new Set([
'it.fails.concurrent',
'it.fails.sequential',
'it.fails.todo',
'it.extend.skip',
'it.extend.only',
'it.extend.concurrent',
'it.extend.sequential',
'it.extend.todo',
'it.extend.fails',
'it.skipIf.skip',
'it.skipIf.only',
'it.skipIf.concurrent',
Expand All @@ -75,10 +70,6 @@ export const ValidVitestFnCallChains = new Set([
'it.sequential.for',
'it.todo.for',
'it.fails.for',
'it.extend.skipIf',
'it.extend.runIf',
'it.extend.each',
'it.extend.for',
'it.skipIf.each',
'it.skipIf.for',
'it.runIf.each',
Expand Down Expand Up @@ -203,36 +194,6 @@ export const ValidVitestFnCallChains = new Set([
'it.fails.todo.only',
'it.fails.todo.concurrent',
'it.fails.todo.sequential',
'it.extend.skip.only',
'it.extend.skip.concurrent',
'it.extend.skip.sequential',
'it.extend.skip.todo',
'it.extend.skip.fails',
'it.extend.only.skip',
'it.extend.only.concurrent',
'it.extend.only.sequential',
'it.extend.only.todo',
'it.extend.only.fails',
'it.extend.concurrent.skip',
'it.extend.concurrent.only',
'it.extend.concurrent.sequential',
'it.extend.concurrent.todo',
'it.extend.concurrent.fails',
'it.extend.sequential.skip',
'it.extend.sequential.only',
'it.extend.sequential.concurrent',
'it.extend.sequential.todo',
'it.extend.sequential.fails',
'it.extend.todo.skip',
'it.extend.todo.only',
'it.extend.todo.concurrent',
'it.extend.todo.sequential',
'it.extend.todo.fails',
'it.extend.fails.skip',
'it.extend.fails.only',
'it.extend.fails.concurrent',
'it.extend.fails.sequential',
'it.extend.fails.todo',
'it.skipIf.skip.only',
'it.skipIf.skip.concurrent',
'it.skipIf.skip.sequential',
Expand Down Expand Up @@ -353,30 +314,6 @@ export const ValidVitestFnCallChains = new Set([
'it.fails.concurrent.for',
'it.fails.sequential.for',
'it.fails.todo.for',
'it.extend.skipIf.skip',
'it.extend.skipIf.only',
'it.extend.skipIf.concurrent',
'it.extend.skipIf.sequential',
'it.extend.skipIf.todo',
'it.extend.skipIf.fails',
'it.extend.runIf.skip',
'it.extend.runIf.only',
'it.extend.runIf.concurrent',
'it.extend.runIf.sequential',
'it.extend.runIf.todo',
'it.extend.runIf.fails',
'it.extend.skip.each',
'it.extend.only.each',
'it.extend.concurrent.each',
'it.extend.sequential.each',
'it.extend.todo.each',
'it.extend.fails.each',
'it.extend.skip.for',
'it.extend.only.for',
'it.extend.concurrent.for',
'it.extend.sequential.for',
'it.extend.todo.for',
'it.extend.fails.for',
'it.skipIf.skip.each',
'it.skipIf.only.each',
'it.skipIf.concurrent.each',
Expand All @@ -401,18 +338,15 @@ export const ValidVitestFnCallChains = new Set([
'it.runIf.sequential.for',
'it.runIf.todo.for',
'it.runIf.fails.for',
'it.extend.skipIf.each',
'it.extend.skipIf.for',
'it.extend.runIf.each',
'it.extend.runIf.for',
'test',
'test.extend',
'test.scoped',
'test.skip',
'test.only',
'test.concurrent',
'test.sequential',
'test.todo',
'test.fails',
'test.extend',
'test.skipIf',
'test.runIf',
'test.each',
Expand Down Expand Up @@ -447,12 +381,6 @@ export const ValidVitestFnCallChains = new Set([
'test.fails.concurrent',
'test.fails.sequential',
'test.fails.todo',
'test.extend.skip',
'test.extend.only',
'test.extend.concurrent',
'test.extend.sequential',
'test.extend.todo',
'test.extend.fails',
'test.skipIf.skip',
'test.skipIf.only',
'test.skipIf.concurrent',
Expand All @@ -477,10 +405,6 @@ export const ValidVitestFnCallChains = new Set([
'test.sequential.for',
'test.todo.for',
'test.fails.for',
'test.extend.skipIf',
'test.extend.runIf',
'test.extend.each',
'test.extend.for',
'test.skipIf.each',
'test.skipIf.for',
'test.runIf.each',
Expand Down Expand Up @@ -605,36 +529,6 @@ export const ValidVitestFnCallChains = new Set([
'test.fails.todo.only',
'test.fails.todo.concurrent',
'test.fails.todo.sequential',
'test.extend.skip.only',
'test.extend.skip.concurrent',
'test.extend.skip.sequential',
'test.extend.skip.todo',
'test.extend.skip.fails',
'test.extend.only.skip',
'test.extend.only.concurrent',
'test.extend.only.sequential',
'test.extend.only.todo',
'test.extend.only.fails',
'test.extend.concurrent.skip',
'test.extend.concurrent.only',
'test.extend.concurrent.sequential',
'test.extend.concurrent.todo',
'test.extend.concurrent.fails',
'test.extend.sequential.skip',
'test.extend.sequential.only',
'test.extend.sequential.concurrent',
'test.extend.sequential.todo',
'test.extend.sequential.fails',
'test.extend.todo.skip',
'test.extend.todo.only',
'test.extend.todo.concurrent',
'test.extend.todo.sequential',
'test.extend.todo.fails',
'test.extend.fails.skip',
'test.extend.fails.only',
'test.extend.fails.concurrent',
'test.extend.fails.sequential',
'test.extend.fails.todo',
'test.skipIf.skip.only',
'test.skipIf.skip.concurrent',
'test.skipIf.skip.sequential',
Expand Down Expand Up @@ -755,30 +649,6 @@ export const ValidVitestFnCallChains = new Set([
'test.fails.concurrent.for',
'test.fails.sequential.for',
'test.fails.todo.for',
'test.extend.skipIf.skip',
'test.extend.skipIf.only',
'test.extend.skipIf.concurrent',
'test.extend.skipIf.sequential',
'test.extend.skipIf.todo',
'test.extend.skipIf.fails',
'test.extend.runIf.skip',
'test.extend.runIf.only',
'test.extend.runIf.concurrent',
'test.extend.runIf.sequential',
'test.extend.runIf.todo',
'test.extend.runIf.fails',
'test.extend.skip.each',
'test.extend.only.each',
'test.extend.concurrent.each',
'test.extend.sequential.each',
'test.extend.todo.each',
'test.extend.fails.each',
'test.extend.skip.for',
'test.extend.only.for',
'test.extend.concurrent.for',
'test.extend.sequential.for',
'test.extend.todo.for',
'test.extend.fails.for',
'test.skipIf.skip.each',
'test.skipIf.only.each',
'test.skipIf.concurrent.each',
Expand All @@ -803,10 +673,6 @@ export const ValidVitestFnCallChains = new Set([
'test.runIf.sequential.for',
'test.runIf.todo.for',
'test.runIf.fails.for',
'test.extend.skipIf.each',
'test.extend.skipIf.for',
'test.extend.runIf.each',
'test.extend.runIf.for',
'bench',
'bench.skip',
'bench.only',
Expand Down
1 change: 0 additions & 1 deletion tests/no-standalone-expect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ ruleTester.run(RULE_NAME, rule, {
'it("an it", () => expect(1).toBe(1))',
'it.only("an it", () => expect(1).toBe(1))',
'it.concurrent("an it", () => expect(1).toBe(1))',
'it.extend.skip("an it", () => expect(1).toBe(1))',
'test("a test", () => expect(1).toBe(1))',
'test.skip("a skipped test", () => expect(1).toBe(1))',
'test.fails("a failing test", () => expect(1).toBe(1))',
Expand Down
3 changes: 3 additions & 0 deletions tests/require-hook.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ ruleTester.run(RULE_NAME, rule, {
test('something', () => {
expect(true).toBe(true);
}));`,
`describe('scoped', () => {
test.scoped({ example: 'value' });
});`,
{
code: `
import { myFn } from '../functions';
Expand Down
Loading