|
| 1 | +import rule, { RULE_NAME } from '../src/rules/require-local-test-context-for-concurrent-snapshots' |
| 2 | +import { ruleTester } from "./ruleTester"; |
| 3 | + |
| 4 | +ruleTester.run(RULE_NAME, rule, { |
| 5 | + valid: [ |
| 6 | + 'it("something", () => { expect(true).toBe(true) })', |
| 7 | + 'it.concurrent("something", () => { expect(true).toBe(true) })', |
| 8 | + 'it("something", () => { expect(1).toMatchSnapshot() })', |
| 9 | + 'it.concurrent("something", ({ expect }) => { expect(1).toMatchSnapshot() })', |
| 10 | + 'it.concurrent("something", ({ expect }) => { expect(1).toMatchInlineSnapshot("1") })', |
| 11 | + 'describe.concurrent("something", () => { it("something", () => { expect(true).toBe(true) }) })', |
| 12 | + 'describe.concurrent("something", () => { it("something", ({ expect }) => { expect(1).toMatchSnapshot() }) })', |
| 13 | + 'describe.concurrent("something", () => { it("something", ({ expect }) => { expect(1).toMatchInlineSnapshot() }) })', |
| 14 | + 'describe("something", () => { it("something", ({ expect }) => { expect(1).toMatchInlineSnapshot() }) })', |
| 15 | + 'describe("something", () => { it("something", (context) => { expect(1).toMatchInlineSnapshot() }) })', |
| 16 | + 'describe("something", () => { it("something", (context) => { context.expect(1).toMatchInlineSnapshot() }) })', |
| 17 | + 'describe("something", () => { it("something", (context) => { expect(1).toMatchInlineSnapshot() }) })', |
| 18 | + 'it.concurrent("something", (context) => { context.expect(1).toMatchSnapshot() })', |
| 19 | + ], |
| 20 | + invalid: [ |
| 21 | + { |
| 22 | + code: 'it.concurrent("should fail", () => { expect(true).toMatchSnapshot() })', |
| 23 | + errors: [{ messageId: 'requireLocalTestContext' }] |
| 24 | + }, |
| 25 | + { |
| 26 | + code: 'it.concurrent("should fail", () => { expect(true).toMatchInlineSnapshot("true") })', |
| 27 | + errors: [{ messageId: 'requireLocalTestContext' }] |
| 28 | + }, |
| 29 | + { |
| 30 | + code: 'describe.concurrent("failing", () => { it("should fail", () => { expect(true).toMatchSnapshot() }) })', |
| 31 | + errors: [{ messageId: 'requireLocalTestContext' }] |
| 32 | + }, |
| 33 | + { |
| 34 | + code: 'describe.concurrent("failing", () => { it("should fail", () => { expect(true).toMatchInlineSnapshot("true") }) })', |
| 35 | + errors: [{ messageId: 'requireLocalTestContext' }] |
| 36 | + }, |
| 37 | + { |
| 38 | + code: 'it.concurrent("something", (context) => { expect(true).toMatchSnapshot() })', |
| 39 | + errors: [{ messageId: 'requireLocalTestContext' }] |
| 40 | + }, |
| 41 | + { |
| 42 | + code: `it.concurrent("something", () => { |
| 43 | + expect(true).toMatchSnapshot(); |
| 44 | +
|
| 45 | + expect(true).toMatchSnapshot(); |
| 46 | + })`, |
| 47 | + errors: [{ messageId: 'requireLocalTestContext' }, { messageId: 'requireLocalTestContext' }] |
| 48 | + }, |
| 49 | + { |
| 50 | + code: `it.concurrent("something", () => { |
| 51 | + expect(true).toBe(true); |
| 52 | +
|
| 53 | + expect(true).toMatchSnapshot(); |
| 54 | + })`, |
| 55 | + errors: [{ messageId: 'requireLocalTestContext' }] |
| 56 | + }, |
| 57 | + ], |
| 58 | +}) |
0 commit comments