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 1d1e8e5
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// vite.config.ts
import { defineConfig } from "file:///Users/marty/azoth/vitest/packages/vitest/dist/config.js";

Check failure on line 2 in examples/react-mui/vite.config.ts.timestamp-1703021587204-0d7b426c092fa.mjs

View workflow job for this annotation

GitHub Actions / lint

Expected 1 empty line after import statement not followed by another import

Check failure on line 2 in examples/react-mui/vite.config.ts.timestamp-1703021587204-0d7b426c092fa.mjs

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote

Check failure on line 2 in examples/react-mui/vite.config.ts.timestamp-1703021587204-0d7b426c092fa.mjs

View workflow job for this annotation

GitHub Actions / lint

Extra semicolon
var vite_config_default = defineConfig({

Check failure on line 3 in examples/react-mui/vite.config.ts.timestamp-1703021587204-0d7b426c092fa.mjs

View workflow job for this annotation

GitHub Actions / lint

Unexpected var, use let or const instead

Check failure on line 3 in examples/react-mui/vite.config.ts.timestamp-1703021587204-0d7b426c092fa.mjs

View workflow job for this annotation

GitHub Actions / lint

Exporting mutable 'var' binding, use 'const' instead
esbuild: {
jsxInject: "import React from 'react'"

Check failure on line 5 in examples/react-mui/vite.config.ts.timestamp-1703021587204-0d7b426c092fa.mjs

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote

Check failure on line 5 in examples/react-mui/vite.config.ts.timestamp-1703021587204-0d7b426c092fa.mjs

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
},
test: {
environment: "jsdom",

Check failure on line 8 in examples/react-mui/vite.config.ts.timestamp-1703021587204-0d7b426c092fa.mjs

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote
globals: true

Check failure on line 9 in examples/react-mui/vite.config.ts.timestamp-1703021587204-0d7b426c092fa.mjs

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
}

Check failure on line 10 in examples/react-mui/vite.config.ts.timestamp-1703021587204-0d7b426c092fa.mjs

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
});
export {
vite_config_default as default
};
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCIvVXNlcnMvbWFydHkvYXpvdGgvdml0ZXN0L2V4YW1wbGVzL3JlYWN0LW11aVwiO2NvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9maWxlbmFtZSA9IFwiL1VzZXJzL21hcnR5L2F6b3RoL3ZpdGVzdC9leGFtcGxlcy9yZWFjdC1tdWkvdml0ZS5jb25maWcudHNcIjtjb25zdCBfX3ZpdGVfaW5qZWN0ZWRfb3JpZ2luYWxfaW1wb3J0X21ldGFfdXJsID0gXCJmaWxlOi8vL1VzZXJzL21hcnR5L2F6b3RoL3ZpdGVzdC9leGFtcGxlcy9yZWFjdC1tdWkvdml0ZS5jb25maWcudHNcIjtpbXBvcnQgeyBkZWZpbmVDb25maWcgfSBmcm9tICd2aXRlc3QvY29uZmlnJ1xuXG5leHBvcnQgZGVmYXVsdCBkZWZpbmVDb25maWcoe1xuICBlc2J1aWxkOiB7XG4gICAganN4SW5qZWN0OiAnaW1wb3J0IFJlYWN0IGZyb20gXFwncmVhY3RcXCcnLFxuICB9LFxuICB0ZXN0OiB7XG4gICAgZW52aXJvbm1lbnQ6ICdqc2RvbScsXG4gICAgZ2xvYmFsczogdHJ1ZSxcbiAgfSxcbn0pXG4iXSwKICAibWFwcGluZ3MiOiAiO0FBQXNULFNBQVMsb0JBQW9CO0FBRW5WLElBQU8sc0JBQVEsYUFBYTtBQUFBLEVBQzFCLFNBQVM7QUFBQSxJQUNQLFdBQVc7QUFBQSxFQUNiO0FBQUEsRUFDQSxNQUFNO0FBQUEsSUFDSixhQUFhO0FBQUEsSUFDYixTQUFTO0FBQUEsRUFDWDtBQUNGLENBQUM7IiwKICAibmFtZXMiOiBbXQp9Cg==
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 1d1e8e5

Please sign in to comment.