Skip to content

Commit 1a516a0

Browse files
committed
Disable 'vitest/prefer-called-exactly-once-with' for now
1 parent dcb6311 commit 1a516a0

7 files changed

Lines changed: 30 additions & 37 deletions

File tree

‎eslint.config.js‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ export default defineConfig(
5454
},
5555
{
5656
files: ['**/*.spec.ts'],
57-
...pluginVitest.configs.recommended,
57+
plugins: {
58+
vitest: pluginVitest,
59+
},
60+
rules: {
61+
...pluginVitest.configs.recommended.rules,
62+
// Currently produces false positives, see https://github.com/vitest-dev/eslint-plugin-vitest/issues/775
63+
'vitest/prefer-called-exactly-once-with': 'off',
64+
},
5865
},
5966
pluginPrettierRecommended,
6067
);

‎src/command.spec.ts‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ describe('#start()', () => {
100100
const { command } = createCommand({}, { detached: true });
101101
command.start();
102102

103-
expect(spawn).toHaveBeenCalledTimes(1);
104-
expect(spawn).toHaveBeenCalledWith(command.command, { detached: true });
103+
expect(spawn).toHaveBeenCalledExactlyOnceWith(command.command, { detached: true });
105104
});
106105

107106
it('sets stdin, process and PID', () => {
@@ -447,16 +446,14 @@ describe('#kill()', () => {
447446
createdCommand.command.start();
448447
createdCommand.command.kill();
449448

450-
expect(killProcess).toHaveBeenCalledTimes(1);
451-
expect(killProcess).toHaveBeenCalledWith(createdCommand.command.pid, undefined);
449+
expect(killProcess).toHaveBeenCalledExactlyOnceWith(createdCommand.command.pid, undefined);
452450
});
453451

454452
it('kills process with some signal', () => {
455453
createdCommand.command.start();
456454
createdCommand.command.kill('SIGKILL');
457455

458-
expect(killProcess).toHaveBeenCalledTimes(1);
459-
expect(killProcess).toHaveBeenCalledWith(createdCommand.command.pid, 'SIGKILL');
456+
expect(killProcess).toHaveBeenCalledExactlyOnceWith(createdCommand.command.pid, 'SIGKILL');
460457
});
461458

462459
it('does not try to kill inexistent process', () => {

‎src/flow-control/input-handler.spec.ts‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ it('forwards input stream to default target ID', () => {
4848

4949
inputStream.write('something');
5050

51-
expect(commands[0].stdin?.write).toHaveBeenCalledTimes(1);
52-
expect(commands[0].stdin?.write).toHaveBeenCalledWith('something');
51+
expect(commands[0].stdin?.write).toHaveBeenCalledExactlyOnceWith('something');
5352
expect(commands[1].stdin?.write).not.toHaveBeenCalled();
5453
});
5554

@@ -90,8 +89,7 @@ it('does not forward input stream when input contains colon in a different forma
9089
inputStream.emit('data', Buffer.from('{:ruby_key=>:my_val}'));
9190
inputStream.emit('data', Buffer.from('js_obj = {key: "my_val"}'));
9291

93-
expect(commands[1].stdin?.write).toHaveBeenCalledTimes(1);
94-
expect(commands[1].stdin?.write).toHaveBeenCalledWith('Ruby1::Const::Syntax');
92+
expect(commands[1].stdin?.write).toHaveBeenCalledExactlyOnceWith('Ruby1::Const::Syntax');
9593
expect(commands[0].stdin?.write).toHaveBeenCalledTimes(6);
9694
expect(commands[0].stdin?.write).toHaveBeenCalledWith('Ruby0::Const::Syntax');
9795
expect(commands[0].stdin?.write).toHaveBeenCalledWith('ruby_symbol_arg :my_symbol');
@@ -107,8 +105,7 @@ it('forwards input stream to target name specified in input', () => {
107105
inputStream.write('bar:something');
108106

109107
expect(commands[0].stdin?.write).not.toHaveBeenCalled();
110-
expect(commands[1].stdin?.write).toHaveBeenCalledTimes(1);
111-
expect(commands[1].stdin?.write).toHaveBeenCalledWith('something');
108+
expect(commands[1].stdin?.write).toHaveBeenCalledExactlyOnceWith('something');
112109
});
113110

114111
it('logs error if command has no stdin open', () => {
@@ -128,8 +125,7 @@ it('fallback to default input stream if command is not found', () => {
128125

129126
inputStream.write('foobar:something');
130127

131-
expect(commands[0].stdin?.write).toHaveBeenCalledTimes(1);
132-
expect(commands[0].stdin?.write).toHaveBeenCalledWith('foobar:something');
128+
expect(commands[0].stdin?.write).toHaveBeenCalledExactlyOnceWith('foobar:something');
133129
expect(commands[1].stdin?.write).not.toHaveBeenCalled();
134130
expect(logger.logGlobalEvent).not.toHaveBeenCalled();
135131
});

‎src/flow-control/kill-others.spec.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ describe.each(['success', 'failure'] as const)('on %s', (condition) => {
6565
assignProcess(commands[1]);
6666
commands[0].close.next(createFakeCloseEvent({ exitCode }));
6767

68-
expect(logger.logGlobalEvent).toHaveBeenCalledTimes(1);
69-
expect(logger.logGlobalEvent).toHaveBeenCalledWith('Sending SIGTERM to other processes..');
68+
expect(logger.logGlobalEvent).toHaveBeenCalledExactlyOnceWith(
69+
'Sending SIGTERM to other processes..',
70+
);
7071
expect(commands[0].kill).not.toHaveBeenCalled();
7172
expect(commands[1].kill).toHaveBeenCalledWith(undefined);
7273
});
@@ -76,8 +77,9 @@ describe.each(['success', 'failure'] as const)('on %s', (condition) => {
7677
assignProcess(commands[1]);
7778
commands[0].close.next(createFakeCloseEvent({ exitCode }));
7879

79-
expect(logger.logGlobalEvent).toHaveBeenCalledTimes(1);
80-
expect(logger.logGlobalEvent).toHaveBeenCalledWith('Sending SIGKILL to other processes..');
80+
expect(logger.logGlobalEvent).toHaveBeenCalledExactlyOnceWith(
81+
'Sending SIGKILL to other processes..',
82+
);
8183
expect(commands[0].kill).not.toHaveBeenCalled();
8284
expect(commands[1].kill).toHaveBeenCalledWith('SIGKILL');
8385
});

‎src/flow-control/log-timings.spec.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,9 @@ it('logs the sorted timings summary when all processes close successfully after
123123

124124
onFinish?.();
125125

126-
expect(logger.logGlobalEvent).toHaveBeenCalledTimes(1);
127-
expect(logger.logGlobalEvent).toHaveBeenCalledWith('Timings:');
128-
expect(logger.logTable).toHaveBeenCalledTimes(1);
126+
expect(logger.logGlobalEvent).toHaveBeenCalledExactlyOnceWith('Timings:');
129127
// sorted by duration
130-
expect(logger.logTable).toHaveBeenCalledWith([
128+
expect(logger.logTable).toHaveBeenCalledExactlyOnceWith([
131129
LogTimings.mapCloseEventToTimingInfo(command1ExitInfo),
132130
LogTimings.mapCloseEventToTimingInfo(command0ExitInfo),
133131
]);

‎src/flow-control/restart-process.spec.ts‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ it('restarts processes that fail immediately, if no delay was passed', () => {
4545
scheduler.flush();
4646

4747
expect(scheduler.now()).toBe(0);
48-
expect(logger.logCommandEvent).toHaveBeenCalledTimes(1);
49-
expect(logger.logCommandEvent).toHaveBeenCalledWith(
48+
expect(logger.logCommandEvent).toHaveBeenCalledExactlyOnceWith(
5049
`${commands[0].command} restarted`,
5150
commands[0],
5251
);
@@ -62,8 +61,7 @@ it('restarts processes that fail after delay ms has passed', () => {
6261
scheduler.flush();
6362

6463
expect(scheduler.now()).toBe(100);
65-
expect(logger.logCommandEvent).toHaveBeenCalledTimes(1);
66-
expect(logger.logCommandEvent).toHaveBeenCalledWith(
64+
expect(logger.logCommandEvent).toHaveBeenCalledExactlyOnceWith(
6765
`${commands[0].command} restarted`,
6866
commands[0],
6967
);
@@ -125,8 +123,7 @@ it('restarts processes until they succeed', () => {
125123

126124
scheduler.flush();
127125

128-
expect(logger.logCommandEvent).toHaveBeenCalledTimes(1);
129-
expect(logger.logCommandEvent).toHaveBeenCalledWith(
126+
expect(logger.logCommandEvent).toHaveBeenCalledExactlyOnceWith(
130127
`${commands[0].command} restarted`,
131128
commands[0],
132129
);

‎src/output-writer.spec.ts‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,15 @@ describe('#write()', () => {
4949
it('writes instantly', () => {
5050
const writer = createWriter({ group: false });
5151
writer.write(commands[2], 'hello');
52-
expect(outputStream.write).toHaveBeenCalledTimes(1);
53-
expect(outputStream.write).toHaveBeenCalledWith('hello');
52+
expect(outputStream.write).toHaveBeenCalledExactlyOnceWith('hello');
5453
});
5554
});
5655

5756
describe('with group=true', () => {
5857
it('writes for null commands', () => {
5958
const writer = createWriter({ group: true });
6059
writer.write(undefined, 'hello');
61-
expect(outputStream.write).toHaveBeenCalledTimes(1);
62-
expect(outputStream.write).toHaveBeenCalledWith('hello');
60+
expect(outputStream.write).toHaveBeenCalledExactlyOnceWith('hello');
6361
});
6462

6563
it('does not write instantly for non-active command', () => {
@@ -72,8 +70,7 @@ describe('#write()', () => {
7270
it('write instantly for active command', () => {
7371
const writer = createWriter({ group: true });
7472
writer.write(commands[0], 'hello');
75-
expect(outputStream.write).toHaveBeenCalledTimes(1);
76-
expect(outputStream.write).toHaveBeenCalledWith('hello');
73+
expect(outputStream.write).toHaveBeenCalledExactlyOnceWith('hello');
7774
});
7875

7976
it('does not wait for write from next command to flush', () => {
@@ -108,8 +105,7 @@ describe('#write()', () => {
108105
closeCommand(commands[2]);
109106
expect(outputStream.write).toHaveBeenCalledTimes(0);
110107
closeCommand(commands[0]);
111-
expect(outputStream.write).toHaveBeenCalledTimes(1);
112-
expect(outputStream.write).toHaveBeenCalledWith('hello');
108+
expect(outputStream.write).toHaveBeenCalledExactlyOnceWith('hello');
113109
expect(writer.activeCommandIndex).toBe(2);
114110
});
115111
});

0 commit comments

Comments
 (0)