From e0768a10816f2ce24e8f713ea5c1bc07cefd5e57 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Thu, 31 Oct 2024 17:26:29 +0900 Subject: [PATCH] test: cleanup --- .../test/__snapshots__/repro2.test.ts.snap | 5 -- test/core/test/repro1.test.ts | 48 --------------- test/core/test/repro2.test.ts | 21 ------- .../__snapshots__/retry-file.test.ts.snap} | 0 .../__snapshots__/retry.test.ts.snap | 17 ------ .../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 +- 11 files changed, 26 insertions(+), 171 deletions(-) delete mode 100644 test/core/test/__snapshots__/repro2.test.ts.snap delete mode 100644 test/core/test/repro1.test.ts delete mode 100644 test/core/test/repro2.test.ts rename test/{core/test/__snapshots__/repro1.test.ts.snap => snapshots/test-update/__snapshots__/retry-file.test.ts.snap} (100%) delete mode 100644 test/snapshots/test-update/__snapshots__/retry.test.ts.snap 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/core/test/__snapshots__/repro2.test.ts.snap b/test/core/test/__snapshots__/repro2.test.ts.snap deleted file mode 100644 index c1acf6864dfd..000000000000 --- a/test/core/test/__snapshots__/repro2.test.ts.snap +++ /dev/null @@ -1,5 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`file same title 1`] = `"foo"`; - -exports[`file same title 2`] = `"bar"`; diff --git a/test/core/test/repro1.test.ts b/test/core/test/repro1.test.ts deleted file mode 100644 index ec0c8149fefe..000000000000 --- a/test/core/test/repro1.test.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { expect, test } from 'vitest' - -test('repro', () => { - expect(0).toBe(0) -}) - -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() -}) - -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() -}) diff --git a/test/core/test/repro2.test.ts b/test/core/test/repro2.test.ts deleted file mode 100644 index 7956a82fea03..000000000000 --- a/test/core/test/repro2.test.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { expect, test } from 'vitest' - -test('repro', () => { - expect(0).toBe(0) -}) - -test('inline same title', () => { - expect('foo').toMatchInlineSnapshot(`"foo"`) -}) - -test('inline same title', () => { - expect('bar').toMatchInlineSnapshot(`"bar"`) -}) - -test('file same title', () => { - expect('foo').toMatchSnapshot() -}) - -test('file same title', () => { - expect('bar').toMatchSnapshot() -}) diff --git a/test/core/test/__snapshots__/repro1.test.ts.snap b/test/snapshots/test-update/__snapshots__/retry-file.test.ts.snap similarity index 100% rename from test/core/test/__snapshots__/repro1.test.ts.snap rename to test/snapshots/test-update/__snapshots__/retry-file.test.ts.snap diff --git a/test/snapshots/test-update/__snapshots__/retry.test.ts.snap b/test/snapshots/test-update/__snapshots__/retry.test.ts.snap deleted file mode 100644 index 55fb93d2deec..000000000000 --- a/test/snapshots/test-update/__snapshots__/retry.test.ts.snap +++ /dev/null @@ -1,17 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`file repeats 1`] = `"foo"`; - -exports[`file repeats many 1`] = `"foo"`; - -exports[`file repeats many 2`] = `"bar"`; - -exports[`file retry 1`] = `"foo"`; - -exports[`file retry many 1`] = `"foo"`; - -exports[`file retry many 2`] = `"bar"`; - -exports[`file retry partial 1`] = `"foo"`; - -exports[`file retry partial 2`] = `"bar"`; 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 cb99fc99e2ee..a8a31a8f58d8 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 000000000000..0d93ccf02176 --- /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 f7fb628944a4..3321ee7ef68e 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 f8c9e0f8146c..a8a31a8f58d8 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 000000000000..9af58c26d837 --- /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 abeed679776e..acb0fb69ecf6 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()