Skip to content

Commit

Permalink
repo test for concurrent test suite not updating inline snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
martypdx committed Dec 19, 2023
1 parent 9497f48 commit 99c5992
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 3 deletions.
19 changes: 19 additions & 0 deletions test/snapshots/test-update/snapshots-inline-concurrent-js.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { describe, it } from 'vitest'

describe.concurrent('suite name', () => {
it('snapshot 1', ({ expect }) => {
expect({ foo: 'foo' }).toMatchInlineSnapshot()
})

it('snapshot 2', ({ expect }) => {
expect({ foo: 'bar' }).toMatchInlineSnapshot()
})

it('snapshot 3', ({ expect }) => {
expect({ foo: 'qux' }).toMatchInlineSnapshot(`
Object {
"foo": "qux",
}
`)
})
})
31 changes: 31 additions & 0 deletions test/snapshots/test/__snapshots__/shapshots.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`js inline concurrent snapshots generated correctly 1`] = `
"import { describe, it } from 'vitest'
describe('suite name', () => {
it('snapshot 1', ({ expect }) => {
expect({ foo: 'foo' }).toMatchInlineSnapshot(\`
Object {
"foo": "foo",
}
\`)
})
it('snapshot 2', ({ expect }) => {
expect({ foo: 'bar' }).toMatchInlineSnapshot(\`
Object {
"foo": "bar",
}
\`)
})
it('snapshot 3', ({ expect }) => {
expect({ foo: 'qux' }).toMatchInlineSnapshot(\`
Object {
"foo": "qux",
}
\`)
})
})
"
`;
exports[`js snapshots generated correctly 1`] = `
"import { describe, expect, test } from 'vitest'
Expand Down
6 changes: 6 additions & 0 deletions test/snapshots/test/shapshots.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,9 @@ test('js snapshots generated correctly', async () => {
const content = await fs.readFile(path, 'utf8')
expect(content).toMatchSnapshot()
})

test('js inline concurrent snapshots generated correctly', async () => {
const path = pathe.resolve(__dirname, '../test-update/snapshots-inline-concurrent-js.test.js')
const content = await fs.readFile(path, 'utf8')
expect(content).toMatchSnapshot()
})
11 changes: 8 additions & 3 deletions test/snapshots/tools/generate-inline-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ export async function generateInlineTest(templatePath, testPath) {
console.warn(`Generated ${testPath}`)
}

const filepath = resolve(dir, '../test-update/snapshots-inline-js.test.js')
const template = resolve(dir, './inline-test-template.js');
const filepath1 = resolve(dir, '../test-update/snapshots-inline-js.test.js')
const template1 = resolve(dir, './inline-test-template.js')
const filepath2 = resolve(dir, '../test-update/snapshots-inline-concurrent-js.test.js')
const template2 = resolve(dir, './inline-test-template-concurrent.js');

(async () => {
await generateInlineTest(template, filepath)
await Promise.all([
generateInlineTest(template1, filepath1),
generateInlineTest(template2, filepath2),
])
})()
19 changes: 19 additions & 0 deletions test/snapshots/tools/inline-test-template-concurrent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { describe, it } from 'vitest'

describe.concurrent('suite name', () => {
it('snapshot 1', ({ expect }) => {
expect({ foo: 'foo' }).toMatchInlineSnapshot()
})

it('snapshot 2', ({ expect }) => {
expect({ foo: 'bar' }).toMatchInlineSnapshot()
})

it('snapshot 3', ({ expect }) => {
expect({ foo: 'qux' }).toMatchInlineSnapshot(`
{
"foo": "qux",
}
`)
})
})

0 comments on commit 99c5992

Please sign in to comment.