Skip to content

Commit 71c76d7

Browse files
committed
Ugly (temp) TypeScript fixes
1 parent 987aff6 commit 71c76d7

5 files changed

Lines changed: 7 additions & 8 deletions

File tree

src/command-parser/expand-npm-wildcard.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@ import { CommandInfo } from '../command.js';
55
import { ExpandNpmWildcard } from './expand-npm-wildcard.js';
66

77
let parser: ExpandNpmWildcard;
8-
let readPkg: jest.Mock;
8+
const readPkg = jest.fn();
99

1010
const createCommandInfo = (command: string): CommandInfo => ({
1111
command,
1212
name: '',
1313
});
1414

1515
beforeEach(() => {
16-
readPkg = jest.fn();
1716
parser = new ExpandNpmWildcard(readPkg);
1817
});
1918

2019
afterEach(() => {
21-
jest.restoreAllMocks();
20+
readPkg.mockClear();
2221
});
2322

2423
describe('ExpandNpmWildcard#readPackage', () => {

src/command.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ beforeEach(() => {
3131
},
3232
});
3333
})();
34-
spawn = jest.fn().mockReturnValue(process);
34+
spawn = jest.fn().mockReturnValue(process) as jest.Mocked<SpawnCommand>;
3535
killProcess = jest.fn();
3636
});
3737

src/concurrently.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ beforeEach(() => {
2929
controllers = [
3030
{ handle: jest.fn((commands) => ({ commands, onFinish: onFinishHooks[0] })) },
3131
{ handle: jest.fn((commands) => ({ commands, onFinish: onFinishHooks[1] })) },
32-
];
32+
] as jest.Mocked<FlowController>[];
3333
});
3434

3535
it('fails if commands is not an array', () => {

src/fixtures/fake-command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class FakeCommand extends Command {
2121
...info,
2222
},
2323
{},
24-
jest.fn(),
24+
jest.fn() as jest.Mock<ChildProcess>,
2525
jest.fn()
2626
);
2727

src/logger.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import chalk from 'chalk';
44
import { FakeCommand } from './fixtures/fake-command.js';
55
import { Logger } from './logger.js';
66

7-
let emitSpy: jest.SpyInstance;
7+
let emitSpy: unknown;
88

99
beforeEach(() => {
1010
// Force chalk to use colours, otherwise tests may pass when they were supposed to be failing.
@@ -40,7 +40,7 @@ describe('#log()', () => {
4040
it('does not prepend prefix if last call did not finish with a LF', () => {
4141
const logger = createLogger({});
4242
logger.log('foo', 'bar');
43-
emitSpy.mockClear();
43+
(emitSpy as jest.SpyInstance).mockClear();
4444
logger.log('foo', 'baz');
4545

4646
expect(logger.emit).toHaveBeenCalledTimes(1);

0 commit comments

Comments
 (0)