Skip to content

Commit a04d66d

Browse files
author
Josh Calder
authored
Fix Prisma test using --frozen (#8767)
1 parent 02798c6 commit a04d66d

File tree

3 files changed

+38
-19
lines changed

3 files changed

+38
-19
lines changed

tests/cli-tests/artifacts.test.ts

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,38 @@ import {
1010
testdir,
1111
} from './utils';
1212

13-
describe.each(['postinstall', ['build', '--frozen'], ['prisma', 'migrate', 'status']])(
14-
'%s',
15-
command => {
16-
test('logs an error and exits with 1 when the schemas do not exist', async () => {
17-
const tmp = await testdir({
18-
...symlinkKeystoneDeps,
19-
'keystone.js': basicKeystoneConfig,
20-
});
21-
const recording = recordConsole();
22-
await expect(runCommand(tmp, command)).rejects.toEqual(new ExitError(1));
23-
expect(recording()).toMatchInlineSnapshot(
24-
`"Your Prisma and GraphQL schemas are not up to date"`
25-
);
13+
describe.each(['postinstall', ['build', '--frozen']])('%s', command => {
14+
test('logs an error and exits with 1 when the schemas do not exist', async () => {
15+
const tmp = await testdir({
16+
...symlinkKeystoneDeps,
17+
'keystone.js': basicKeystoneConfig,
18+
});
19+
const recording = recordConsole();
20+
await expect(runCommand(tmp, command)).rejects.toEqual(new ExitError(1));
21+
expect(recording()).toMatchInlineSnapshot(
22+
`"Your Prisma and GraphQL schemas are not up to date"`
23+
);
24+
});
25+
});
26+
27+
describe('prisma migrate status', () => {
28+
test('logs an error and exits with 1 when the schemas do not exist', async () => {
29+
const tmp = await testdir({
30+
...symlinkKeystoneDeps,
31+
'keystone.js': basicKeystoneConfig,
2632
});
27-
}
28-
);
33+
await expect(runCommand(tmp, ['build', '--no-ui', '--frozen'])).rejects.toEqual(
34+
new ExitError(1)
35+
);
36+
const recording = recordConsole();
37+
await expect(runCommand(tmp, ['prisma', '--frozen', 'migrate', 'status'])).rejects.toEqual(
38+
new ExitError(1)
39+
);
40+
expect(recording()).toMatchInlineSnapshot(
41+
`"Your Prisma and GraphQL schemas are not up to date"`
42+
);
43+
});
44+
});
2945

3046
const schemasMatch = ['schema.prisma', 'schema.graphql'];
3147

tests/cli-tests/migrations.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ describe('useMigrations: false', () => {
248248
}
249249

250250
expect(recording()).toMatchInlineSnapshot(`
251-
"? Starting Keystone
251+
"? Generated GraphQL and Prisma schemas
252+
? Starting Keystone
252253
? Server listening on :3000 (http://localhost:3000/)
253254
? GraphQL API available at /api/graphql
254255
? Generating GraphQL and Prisma schemas

tests/cli-tests/prisma.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ test('keystone prisma exits with the same code as the prisma child process exits
1515
cwd: tmp,
1616
});
1717
expect(result.all!.replace(/[^ -~\n]/g, '?')).toMatchInlineSnapshot(`
18-
"
18+
"? Generated GraphQL and Prisma schemas
19+
1920
! Unknown command "bad-thing"
2021
2122
? Prisma is a modern DB toolkit to query, migrate and model your database (https://prisma.io)
@@ -79,8 +80,9 @@ test('keystone prisma uses the db url in the keystone config', async () => {
7980
all: true,
8081
cwd: tmp,
8182
});
82-
expect(result.all).toMatchInlineSnapshot(`
83-
"Prisma schema loaded from schema.prisma
83+
expect(result.all!.replace(/[^ -~\n]/g, '?')).toMatchInlineSnapshot(`
84+
"? Generated GraphQL and Prisma schemas
85+
Prisma schema loaded from schema.prisma
8486
Datasource "sqlite": SQLite database "app.db" at "file:./app.db"
8587
Error: P1003: Database app.db does not exist at ./app.db"
8688
`);

0 commit comments

Comments
 (0)