Skip to content

Commit dc854c3

Browse files
committed
Revert skipped and splitted tests
1 parent f95ae7b commit dc854c3

3 files changed

Lines changed: 45 additions & 79 deletions

File tree

packages/graphql-codegen-cli/tests/codegen.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,8 +1096,7 @@ describe('Codegen Executor', () => {
10961096
}
10971097
});
10981098

1099-
// FIXME: Node 16 and graphql-config integration does not work
1100-
it.skip('Should generate documents output even if prj1/documents and prj1/extensions/codegen/generate/xxx/documents are both definded with the same glob files', async () => {
1099+
it('Should generate documents output even if prj1/documents and prj1/extensions/codegen/generate/xxx/documents are both definded with the same glob files', async () => {
11011100
const prj1 = await createContext({
11021101
config: './tests/test-files/graphql.config.js',
11031102
project: 'prj1',

packages/graphql-codegen-cli/tests/generate-and-save.graphql-config.spec.ts

Lines changed: 0 additions & 77 deletions
This file was deleted.

packages/graphql-codegen-cli/tests/generate-and-save.spec.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { dirname, join } from 'path';
22
import { Types } from '@graphql-codegen/plugin-helpers';
33
import { useMonorepo } from '@graphql-codegen/testing';
44
import makeDir from 'make-dir';
5+
import { createContext } from '../src/config.js';
56
import { generate } from '../src/generate-and-save.js';
67
import * as fs from '../src/utils/file-system.js';
78

@@ -380,5 +381,48 @@ describe('generate-and-save', () => {
380381
);
381382
expect(consoleErrorMock).not.toHaveBeenCalled();
382383
});
384+
385+
test('No documents found - GraphQL Config - should throw error by default', async () => {
386+
expect.assertions(1);
387+
try {
388+
const config = await createContext({
389+
config: './tests/test-files/graphql.config.no-doc.js',
390+
project: undefined,
391+
errorsOnly: true,
392+
overwrite: true,
393+
profile: true,
394+
require: [],
395+
silent: false,
396+
watch: false,
397+
});
398+
399+
await generate(config, false);
400+
} catch {
401+
expect(consoleErrorMock.mock.calls[0][0]).toBeSimilarStringTo(`
402+
[FAILED]
403+
[FAILED] Unable to find any GraphQL type definitions for the following pointers:
404+
[FAILED]
405+
[FAILED] - ../test-documents/empty.graphql
406+
`);
407+
}
408+
});
409+
410+
test('No documents found - GraphQL Config - should not fail if ignoreNoDocuments=true', async () => {
411+
jest.spyOn(fs, 'writeFile').mockImplementation();
412+
const config = await createContext({
413+
config: './tests/test-files/graphql.config.no-doc-ignored.js',
414+
project: undefined,
415+
errorsOnly: true,
416+
overwrite: true,
417+
profile: true,
418+
require: [],
419+
silent: false,
420+
watch: false,
421+
});
422+
423+
await generate(config, false);
424+
425+
expect(consoleErrorMock).not.toHaveBeenCalled();
426+
});
383427
});
384428
});

0 commit comments

Comments
 (0)