Skip to content

Commit b32a501

Browse files
committed
Fix tests
1 parent c48c878 commit b32a501

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

packages/commands/diff/__tests__/diff-command.ts renamed to packages/commands/diff/__tests__/diff-command.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ describe('diff', () => {
125125
expect(spyReporter).not.toHaveBeenCalledNormalized('does not exist');
126126
});
127127

128-
test.only('should render error if file does not exist', async () => {
128+
test('should render error if file does not exist', async () => {
129129
await mockCommand(diff, `diff old.graphql new.graphql --rule noop.js`);
130130

131131
expect(spyReporter).toHaveBeenCalledNormalized('does not exist');

packages/commands/introspect/__tests__/introspect-command.spec.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ import {mockCommand} from '@graphql-inspector/commands';
55
import {mockLogger, unmockLogger} from '@graphql-inspector/logger';
66
import yargs from 'yargs';
77
import {buildSchema} from 'graphql';
8+
import {unlinkSync, existsSync} from 'fs';
89
import createCommand from '../src';
910

11+
function sleepFor(ms: number) {
12+
return new Promise((resolve) => {
13+
setTimeout(resolve, ms);
14+
});
15+
}
16+
1017
const schema = buildSchema(/* GraphQL */ `
1118
type Post {
1219
id: ID!
@@ -33,13 +40,10 @@ const introspect = createCommand({
3340

3441
describe('introspect', () => {
3542
let spyReporter: jest.SpyInstance;
36-
let spyProcessExit: jest.SpyInstance;
3743
let spyProcessCwd: jest.SpyInstance;
3844

3945
beforeEach(() => {
4046
yargs.reset();
41-
spyProcessExit = jest.spyOn(process, 'exit');
42-
spyProcessExit.mockImplementation();
4347

4448
spyProcessCwd = jest
4549
.spyOn(process, 'cwd')
@@ -52,9 +56,9 @@ describe('introspect', () => {
5256
afterEach(() => {
5357
yargs.reset();
5458
unmockLogger();
55-
spyProcessExit.mockRestore();
5659
spyProcessCwd.mockRestore();
5760
spyReporter.mockRestore();
61+
unlinkSync('graphql.schema.json');
5862
});
5963

6064
test('graphql api with port and ws in name using url-loader', async () => {
@@ -64,8 +68,9 @@ describe('introspect', () => {
6468
path: '/graphql',
6569
});
6670
await mockCommand(introspect, 'introspect http://foo.ws:8020/graphql');
71+
await sleepFor(500);
6772

6873
done();
69-
expect(spyProcessExit).toHaveBeenCalledWith(0);
74+
expect(existsSync('graphql.schema.json')).toBe(true);
7075
});
7176
});

0 commit comments

Comments
 (0)