Skip to content

Commit b915706

Browse files
authored
tests: remove eslint-disable jest/no-test-callback (#1312)
* tests: remove eslint-disable jest/no-test-callback Instead of using the `done` callback from the test function, we can be using a Promise instead. I've checked that if `resolve` is not called the test fails (timeout). * fix: code style * test: ensure an assertion is made (code review)
1 parent 8fb669f commit b915706

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

tests/command.exitOverride.test.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -175,19 +175,19 @@ describe('.exitOverride and error details', () => {
175175
expectCommanderError(caughtErr, 0, 'commander.version', myVersion);
176176
});
177177

178-
// Have not worked out a cleaner way to do this, so suppress warning.
179-
// eslint-disable-next-line jest/no-test-callback
180-
test('when executableSubcommand succeeds then call exitOverride', (done) => {
178+
test('when executableSubcommand succeeds then call exitOverride', async() => {
179+
expect.hasAssertions();
181180
const pm = path.join(__dirname, 'fixtures/pm');
182181
const program = new commander.Command();
183-
program
184-
.exitOverride((err) => {
185-
expectCommanderError(err, 0, 'commander.executeSubCommandAsync', '(close)');
186-
done();
187-
})
188-
.command('silent', 'description');
189-
190-
program.parse(['node', pm, 'silent']);
182+
await new Promise((resolve) => {
183+
program
184+
.exitOverride((err) => {
185+
expectCommanderError(err, 0, 'commander.executeSubCommandAsync', '(close)');
186+
resolve();
187+
})
188+
.command('silent', 'description');
189+
program.parse(['node', pm, 'silent']);
190+
});
191191
});
192192

193193
test('when mandatory program option missing then throw CommanderError', () => {

0 commit comments

Comments
 (0)