From 278ada97102371e0fa6e049ce0141a28f192a195 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Thu, 31 Oct 2024 17:26:29 +0900 Subject: [PATCH] test: cleanup --- ...y.test.ts.snap => retry-file.test.ts.snap} | 0 .../retry-file.test.ts} | 11 ---- .../test-update/retry-inline.test.ts | 12 ++++ .../__snapshots__/test-update.test.ts.snap | 58 +------------------ .../fixtures/test-update/retry-file.test.ts} | 11 ---- .../fixtures/test-update/retry-inline.test.ts | 12 ++++ test/snapshots/test/test-update.test.ts | 2 +- 7 files changed, 26 insertions(+), 80 deletions(-) rename test/snapshots/test-update/__snapshots__/{retry.test.ts.snap => retry-file.test.ts.snap} (100%) rename test/snapshots/{test/fixtures/test-update/retry.test.ts => test-update/retry-file.test.ts} (75%) create mode 100644 test/snapshots/test-update/retry-inline.test.ts rename test/snapshots/{test-update/retry.test.ts => test/fixtures/test-update/retry-file.test.ts} (74%) create mode 100644 test/snapshots/test/fixtures/test-update/retry-inline.test.ts diff --git a/test/snapshots/test-update/__snapshots__/retry.test.ts.snap b/test/snapshots/test-update/__snapshots__/retry-file.test.ts.snap similarity index 100% rename from test/snapshots/test-update/__snapshots__/retry.test.ts.snap rename to test/snapshots/test-update/__snapshots__/retry-file.test.ts.snap diff --git a/test/snapshots/test/fixtures/test-update/retry.test.ts b/test/snapshots/test-update/retry-file.test.ts similarity index 75% rename from test/snapshots/test/fixtures/test-update/retry.test.ts rename to test/snapshots/test-update/retry-file.test.ts index cb99fc99e2ee6..a8a31a8f58d86 100644 --- a/test/snapshots/test/fixtures/test-update/retry.test.ts +++ b/test/snapshots/test-update/retry-file.test.ts @@ -1,16 +1,5 @@ import { expect, test } from 'vitest' -test('inline repeats', { repeats: 1 }, () => { - expect('foo').toMatchInlineSnapshot() -}) - -test('inline retry', { retry: 1 }, (ctx) => { - expect('foo').toMatchInlineSnapshot() - if (ctx.task.result?.retryCount === 0) { - throw new Error('boom') - } -}) - test('file repeats', { repeats: 1 }, () => { expect('foo').toMatchSnapshot() }) diff --git a/test/snapshots/test-update/retry-inline.test.ts b/test/snapshots/test-update/retry-inline.test.ts new file mode 100644 index 0000000000000..0d93ccf021766 --- /dev/null +++ b/test/snapshots/test-update/retry-inline.test.ts @@ -0,0 +1,12 @@ +import { expect, test } from 'vitest' + +test('inline repeats', { repeats: 1 }, () => { + expect('foo').toMatchInlineSnapshot(`"foo"`) +}) + +test('inline retry', { retry: 1 }, (ctx) => { + expect('foo').toMatchInlineSnapshot(`"foo"`) + if (ctx.task.result?.retryCount === 0) { + throw new Error('boom') + } +}) diff --git a/test/snapshots/test/__snapshots__/test-update.test.ts.snap b/test/snapshots/test/__snapshots__/test-update.test.ts.snap index f7fb628944a4d..3321ee7ef68e5 100644 --- a/test/snapshots/test/__snapshots__/test-update.test.ts.snap +++ b/test/snapshots/test/__snapshots__/test-update.test.ts.snap @@ -90,7 +90,7 @@ it.concurrent('3rd', ({ expect }) => { " `; -exports[`retry.test.ts 1`] = ` +exports[`retry-inline.test.ts 1`] = ` "import { expect, test } from 'vitest' test('inline repeats', { repeats: 1 }, () => { @@ -103,62 +103,6 @@ test('inline retry', { retry: 1 }, (ctx) => { throw new Error('boom') } }) - -test('file repeats', { repeats: 1 }, () => { - expect('foo').toMatchSnapshot() -}) - -test('file retry', { retry: 1 }, (ctx) => { - expect('foo').toMatchSnapshot() - if (ctx.task.result?.retryCount === 0) { - throw new Error('boom') - } -}) - -test('file repeats many', { repeats: 1 }, () => { - expect('foo').toMatchSnapshot() - expect('bar').toMatchSnapshot() -}) - -test('file retry many', { retry: 1 }, (ctx) => { - expect('foo').toMatchSnapshot() - expect('bar').toMatchSnapshot() - if (ctx.task.result?.retryCount === 0) { - throw new Error('boom') - } -}) - -test('file retry partial', { retry: 1 }, (ctx) => { - expect('foo').toMatchSnapshot() - if (ctx.task.result?.retryCount === 0) { - throw new Error('boom') - } - expect('bar').toMatchSnapshot() -}) -" -`; - -exports[`same-title-file.test.js 1`] = ` -"import { expect, test } from 'vitest' - -test('same title exist', () => { - // correct entry exists in .snap - expect('a').toMatchSnapshot() -}) - -test('same title exist', () => { - // wrong entry exists in .snap - expect('b').toMatchSnapshot() -}) - -test('same title new', () => { - expect('a').toMatchSnapshot() -}) - -test('same title new', () => { - expect('b').toMatchSnapshot() - expect('c').toMatchSnapshot() -}) " `; diff --git a/test/snapshots/test-update/retry.test.ts b/test/snapshots/test/fixtures/test-update/retry-file.test.ts similarity index 74% rename from test/snapshots/test-update/retry.test.ts rename to test/snapshots/test/fixtures/test-update/retry-file.test.ts index f8c9e0f8146c7..a8a31a8f58d86 100644 --- a/test/snapshots/test-update/retry.test.ts +++ b/test/snapshots/test/fixtures/test-update/retry-file.test.ts @@ -1,16 +1,5 @@ import { expect, test } from 'vitest' -test('inline repeats', { repeats: 1 }, () => { - expect('foo').toMatchInlineSnapshot(`"foo"`) -}) - -test('inline retry', { retry: 1 }, (ctx) => { - expect('foo').toMatchInlineSnapshot(`"foo"`) - if (ctx.task.result?.retryCount === 0) { - throw new Error('boom') - } -}) - test('file repeats', { repeats: 1 }, () => { expect('foo').toMatchSnapshot() }) diff --git a/test/snapshots/test/fixtures/test-update/retry-inline.test.ts b/test/snapshots/test/fixtures/test-update/retry-inline.test.ts new file mode 100644 index 0000000000000..9af58c26d8379 --- /dev/null +++ b/test/snapshots/test/fixtures/test-update/retry-inline.test.ts @@ -0,0 +1,12 @@ +import { expect, test } from 'vitest' + +test('inline repeats', { repeats: 1 }, () => { + expect('foo').toMatchInlineSnapshot() +}) + +test('inline retry', { retry: 1 }, (ctx) => { + expect('foo').toMatchInlineSnapshot() + if (ctx.task.result?.retryCount === 0) { + throw new Error('boom') + } +}) diff --git a/test/snapshots/test/test-update.test.ts b/test/snapshots/test/test-update.test.ts index abeed679776e9..acb0fb69ecf67 100644 --- a/test/snapshots/test/test-update.test.ts +++ b/test/snapshots/test/test-update.test.ts @@ -4,7 +4,7 @@ import { expect, test } from 'vitest' const dir = join(import.meta.dirname, '../test-update') const dirents = await fs.readdir(dir, { withFileTypes: true }) -const files = dirents.filter(f => f.isFile()).map(f => f.name) +const files = dirents.filter(f => f.isFile() && f.name.includes('inline')).map(f => f.name) test.for(files)('%s', async (file) => { const content = await fs.readFile(join(dir, file), 'utf8') expect(content).toMatchSnapshot()