jest-to-exit-process
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

jest-to-exit-process

expectで指定した関数が内部でプロセス終了することをテストするためのマッチャーです。

expect(() => {
  process.exit();
}).toExitProcess();

のように使用します。

.toExitProcess(code?)

関数が内部でcodeを指定しprocess.exitを呼ぶことを確認します。

codeの指定を省略した場合は、codeの比較を行いません。

test('testProgram', () => {
  expect(() => {
    testProgram();
  }).toExitProcess();
});

非同期関数を指定する場合にはexpectの前にawaitを忘れないようにしましょう。

test('testProgramAsync', async () => {
  await expect(async () => {
    await testProgramAsync();
  }).toExitProcess(1);
});

Readme

Keywords

none

Package Sidebar

Install

npm i jest-to-exit-process

Weekly Downloads

0

Version

0.0.2

License

none

Unpacked Size

6.01 kB

Total Files

5

Last publish

Collaborators

  • sugoroku-y