runner.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  1. 'use strict';
  2. require('../lib/chalk').set();
  3. require('../lib/worker/options').set({});
  4. const test = require('tap').test;
  5. const Runner = require('../lib/runner');
  6. const slice = Array.prototype.slice;
  7. const noop = () => {};
  8. const promiseEnd = (runner, next) => {
  9. return new Promise(resolve => {
  10. resolve(runner.once('finish'));
  11. next(runner);
  12. }).then(() => runner);
  13. };
  14. test('nested tests and hooks aren\'t allowed', t => {
  15. t.plan(1);
  16. return promiseEnd(new Runner(), runner => {
  17. runner.chain('test', a => {
  18. t.throws(() => {
  19. runner.chain(noop);
  20. }, {message: 'All tests and hooks must be declared synchronously in your test file, and cannot be nested within other tests or hooks.'});
  21. a.pass();
  22. });
  23. });
  24. });
  25. test('tests must be declared synchronously', t => {
  26. t.plan(1);
  27. return promiseEnd(new Runner(), runner => {
  28. runner.chain('test', a => {
  29. a.pass();
  30. return Promise.resolve();
  31. });
  32. }).then(runner => {
  33. t.throws(() => {
  34. runner.chain(noop);
  35. }, {message: 'All tests and hooks must be declared synchronously in your test file, and cannot be nested within other tests or hooks.'});
  36. });
  37. });
  38. test('runner emits "stateChange" events', t => {
  39. const runner = new Runner();
  40. runner.on('stateChange', evt => {
  41. if (evt.type === 'declared-test') {
  42. t.deepEqual(evt, {
  43. type: 'declared-test',
  44. title: 'foo',
  45. knownFailing: false,
  46. todo: false
  47. });
  48. t.end();
  49. }
  50. });
  51. runner.chain('foo', a => {
  52. a.pass();
  53. });
  54. });
  55. test('run serial tests before concurrent ones', t => {
  56. const arr = [];
  57. return promiseEnd(new Runner(), runner => {
  58. runner.chain('test', a => {
  59. arr.push('c');
  60. a.end();
  61. });
  62. runner.chain.serial('serial', a => {
  63. arr.push('a');
  64. a.end();
  65. });
  66. runner.chain.serial('serial 2', a => {
  67. arr.push('b');
  68. a.end();
  69. });
  70. }).then(() => {
  71. t.strictDeepEqual(arr, ['a', 'b', 'c']);
  72. });
  73. });
  74. test('anything can be skipped', t => {
  75. const arr = [];
  76. function pusher(title) {
  77. return a => {
  78. arr.push(title);
  79. a.pass();
  80. };
  81. }
  82. return promiseEnd(new Runner(), runner => {
  83. runner.chain.after(pusher('after'));
  84. runner.chain.after.skip(pusher('after.skip'));
  85. runner.chain.afterEach(pusher('afterEach'));
  86. runner.chain.afterEach.skip(pusher('afterEach.skip'));
  87. runner.chain.before(pusher('before'));
  88. runner.chain.before.skip(pusher('before.skip'));
  89. runner.chain.beforeEach(pusher('beforeEach'));
  90. runner.chain.beforeEach.skip(pusher('beforeEach.skip'));
  91. runner.chain('concurrent', pusher('concurrent'));
  92. runner.chain.skip('concurrent.skip', pusher('concurrent.skip'));
  93. runner.chain.serial('serial', pusher('serial'));
  94. runner.chain.serial.skip('serial.skip', pusher('serial.skip'));
  95. }).then(() => {
  96. // Note that afterEach and beforeEach run twice because there are two actual tests - "serial" and "concurrent"
  97. t.strictDeepEqual(arr, [
  98. 'before',
  99. 'beforeEach',
  100. 'serial',
  101. 'afterEach',
  102. 'beforeEach',
  103. 'concurrent',
  104. 'afterEach',
  105. 'after'
  106. ]);
  107. });
  108. });
  109. test('test types and titles', t => {
  110. t.plan(10);
  111. const fail = a => a.fail();
  112. const pass = a => a.pass();
  113. const check = (setup, expect) => {
  114. const runner = new Runner();
  115. runner.on('stateChange', evt => {
  116. if (evt.type === 'hook-failed' || evt.type === 'test-failed' || evt.type === 'test-passed') {
  117. const expected = expect.shift();
  118. t.is(evt.title, expected.title);
  119. }
  120. });
  121. return promiseEnd(runner, () => setup(runner.chain));
  122. };
  123. return Promise.all([
  124. check(chain => {
  125. chain.before(fail);
  126. chain('test', pass);
  127. }, [
  128. {type: 'before', title: 'before hook'}
  129. ]),
  130. check(chain => {
  131. chain('test', pass);
  132. chain.after(fail);
  133. }, [
  134. {type: 'test', title: 'test'},
  135. {type: 'after', title: 'after hook'}
  136. ]),
  137. check(chain => {
  138. chain('test', pass);
  139. chain.after.always(fail);
  140. }, [
  141. {type: 'test', title: 'test'},
  142. {type: 'after', title: 'after.always hook'}
  143. ]),
  144. check(chain => {
  145. chain.beforeEach(fail);
  146. chain('test', fail);
  147. }, [
  148. {type: 'beforeEach', title: 'beforeEach hook for test'}
  149. ]),
  150. check(chain => {
  151. chain('test', pass);
  152. chain.afterEach(fail);
  153. }, [
  154. {type: 'test', title: 'test'},
  155. {type: 'afterEach', title: 'afterEach hook for test'}
  156. ]),
  157. check(chain => {
  158. chain('test', pass);
  159. chain.afterEach.always(fail);
  160. }, [
  161. {type: 'test', title: 'test'},
  162. {type: 'afterEach', title: 'afterEach.always hook for test'}
  163. ])
  164. ]);
  165. });
  166. test('skip test', t => {
  167. t.plan(3);
  168. const arr = [];
  169. return promiseEnd(new Runner(), runner => {
  170. runner.on('stateChange', evt => {
  171. if (evt.type === 'selected-test' && evt.skip) {
  172. t.pass();
  173. }
  174. if (evt.type === 'test-passed') {
  175. t.pass();
  176. }
  177. });
  178. runner.chain('test', a => {
  179. arr.push('a');
  180. a.pass();
  181. });
  182. runner.chain.skip('skip', () => {
  183. arr.push('b');
  184. });
  185. }).then(() => {
  186. t.strictDeepEqual(arr, ['a']);
  187. });
  188. });
  189. test('tests must have a non-empty title)', t => {
  190. t.plan(1);
  191. return promiseEnd(new Runner(), runner => {
  192. t.throws(() => {
  193. runner.chain('', t => t.pass());
  194. }, new TypeError('Tests must have a title'));
  195. });
  196. });
  197. test('test titles must be unique', t => {
  198. t.plan(1);
  199. return promiseEnd(new Runner(), runner => {
  200. runner.chain('title', t => t.pass());
  201. t.throws(() => {
  202. runner.chain('title', t => t.pass());
  203. }, new Error('Duplicate test title: title'));
  204. });
  205. });
  206. test('tests must have an implementation', t => {
  207. t.plan(1);
  208. const runner = new Runner();
  209. t.throws(() => {
  210. runner.chain('title');
  211. }, new TypeError('Expected an implementation. Use `test.todo()` for tests without an implementation.'));
  212. });
  213. test('todo test', t => {
  214. t.plan(3);
  215. const arr = [];
  216. return promiseEnd(new Runner(), runner => {
  217. runner.on('stateChange', evt => {
  218. if (evt.type === 'selected-test' && evt.todo) {
  219. t.pass();
  220. }
  221. if (evt.type === 'test-passed') {
  222. t.pass();
  223. }
  224. });
  225. runner.chain('test', a => {
  226. arr.push('a');
  227. a.pass();
  228. });
  229. runner.chain.todo('todo');
  230. }).then(() => {
  231. t.strictDeepEqual(arr, ['a']);
  232. });
  233. });
  234. test('todo tests must not have an implementation', t => {
  235. t.plan(1);
  236. return promiseEnd(new Runner(), runner => {
  237. t.throws(() => {
  238. runner.chain.todo('todo', () => {});
  239. }, new TypeError('`todo` tests are not allowed to have an implementation. Use `test.skip()` for tests with an implementation.'));
  240. });
  241. });
  242. test('todo tests must have a title', t => {
  243. t.plan(1);
  244. return promiseEnd(new Runner(), runner => {
  245. t.throws(() => {
  246. runner.chain.todo();
  247. }, new TypeError('`todo` tests require a title'));
  248. });
  249. });
  250. test('todo test titles must be unique', t => {
  251. t.plan(1);
  252. return promiseEnd(new Runner(), runner => {
  253. runner.chain('title', t => t.pass());
  254. t.throws(() => {
  255. runner.chain.todo('title');
  256. }, new Error('Duplicate test title: title'));
  257. });
  258. });
  259. test('only test', t => {
  260. t.plan(2);
  261. const arr = [];
  262. return promiseEnd(new Runner(), runner => {
  263. runner.on('stateChange', evt => {
  264. if (evt.type === 'selected-test') {
  265. t.pass();
  266. }
  267. });
  268. runner.chain('test', a => {
  269. arr.push('a');
  270. a.pass();
  271. });
  272. runner.chain.only('only', a => {
  273. arr.push('b');
  274. a.pass();
  275. });
  276. }).then(() => {
  277. t.strictDeepEqual(arr, ['b']);
  278. });
  279. });
  280. test('options.runOnlyExclusive means only exclusive tests are run', t => {
  281. t.plan(1);
  282. return promiseEnd(new Runner({runOnlyExclusive: true}), runner => {
  283. runner.chain('test', () => {
  284. t.fail();
  285. });
  286. runner.chain.only('test 2', () => {
  287. t.pass();
  288. });
  289. });
  290. });
  291. test('options.serial forces all tests to be serial', t => {
  292. t.plan(1);
  293. const arr = [];
  294. return promiseEnd(new Runner({serial: true}), runner => {
  295. runner.chain.cb('cb', a => {
  296. setTimeout(() => {
  297. arr.push(1);
  298. a.end();
  299. }, 200);
  300. a.pass();
  301. });
  302. runner.chain.cb('cb 2', a => {
  303. setTimeout(() => {
  304. arr.push(2);
  305. a.end();
  306. }, 100);
  307. a.pass();
  308. });
  309. runner.chain('test', a => {
  310. a.pass();
  311. t.strictDeepEqual(arr, [1, 2]);
  312. });
  313. });
  314. });
  315. test('options.failFast does not stop concurrent tests from running', t => {
  316. const expected = ['first', 'second'];
  317. t.plan(expected.length);
  318. promiseEnd(new Runner({failFast: true}), runner => {
  319. let block;
  320. let resume;
  321. runner.chain.beforeEach(() => {
  322. if (block) {
  323. return block;
  324. }
  325. block = new Promise(resolve => {
  326. resume = resolve;
  327. });
  328. });
  329. runner.chain('first', a => {
  330. resume();
  331. a.fail();
  332. });
  333. runner.chain('second', a => {
  334. a.pass();
  335. });
  336. runner.on('stateChange', evt => {
  337. if (evt.type === 'test-failed' || evt.type === 'test-passed') {
  338. t.is(evt.title, expected.shift());
  339. }
  340. });
  341. });
  342. });
  343. test('options.failFast && options.serial stops subsequent tests from running ', t => {
  344. const expected = ['first'];
  345. t.plan(expected.length);
  346. promiseEnd(new Runner({failFast: true, serial: true}), runner => {
  347. let block;
  348. let resume;
  349. runner.chain.beforeEach(() => {
  350. if (block) {
  351. return block;
  352. }
  353. block = new Promise(resolve => {
  354. resume = resolve;
  355. });
  356. });
  357. runner.chain('first', a => {
  358. resume();
  359. a.fail();
  360. });
  361. runner.chain('second', a => {
  362. a.pass();
  363. });
  364. runner.on('stateChange', evt => {
  365. if (evt.type === 'test-failed' || evt.type === 'test-passed') {
  366. t.is(evt.title, expected.shift());
  367. }
  368. });
  369. });
  370. });
  371. test('options.failFast & failing serial test stops subsequent tests from running ', t => {
  372. const expected = ['first'];
  373. t.plan(expected.length);
  374. promiseEnd(new Runner({failFast: true, serial: true}), runner => {
  375. let block;
  376. let resume;
  377. runner.chain.beforeEach(() => {
  378. if (block) {
  379. return block;
  380. }
  381. block = new Promise(resolve => {
  382. resume = resolve;
  383. });
  384. });
  385. runner.chain.serial('first', a => {
  386. resume();
  387. a.fail();
  388. });
  389. runner.chain.serial('second', a => {
  390. a.pass();
  391. });
  392. runner.chain('third', a => {
  393. a.pass();
  394. });
  395. runner.on('stateChange', evt => {
  396. if (evt.type === 'test-failed' || evt.type === 'test-passed') {
  397. t.is(evt.title, expected.shift());
  398. }
  399. });
  400. });
  401. });
  402. test('options.match will not run tests with non-matching titles', t => {
  403. t.plan(4);
  404. return promiseEnd(new Runner({match: ['*oo', '!foo']}), runner => {
  405. runner.on('stateChange', evt => {
  406. if (evt.type === 'test-passed') {
  407. t.pass();
  408. }
  409. });
  410. runner.chain('mhm. grass tasty. moo', a => {
  411. t.pass();
  412. a.pass();
  413. });
  414. runner.chain('juggaloo', a => {
  415. t.pass();
  416. a.pass();
  417. });
  418. runner.chain('foo', a => {
  419. t.fail();
  420. a.pass();
  421. });
  422. runner.chain('test', a => {
  423. t.fail();
  424. a.pass();
  425. });
  426. });
  427. });
  428. test('options.match hold no effect on hooks with titles', t => {
  429. t.plan(2);
  430. return promiseEnd(new Runner({match: ['!before*']}), runner => {
  431. runner.on('stateChange', evt => {
  432. if (evt.type === 'test-passed') {
  433. t.pass();
  434. }
  435. });
  436. let actual;
  437. runner.chain.before('before hook with title', () => {
  438. actual = 'foo';
  439. });
  440. runner.chain('after', a => {
  441. t.is(actual, 'foo');
  442. a.pass();
  443. });
  444. });
  445. });
  446. test('options.match overrides .only', t => {
  447. t.plan(4);
  448. return promiseEnd(new Runner({match: ['*oo']}), runner => {
  449. runner.on('stateChange', evt => {
  450. if (evt.type === 'test-passed') {
  451. t.pass();
  452. }
  453. });
  454. runner.chain('moo', a => {
  455. t.pass();
  456. a.pass();
  457. });
  458. runner.chain.only('boo', a => {
  459. t.pass();
  460. a.pass();
  461. });
  462. });
  463. });
  464. test('options.match matches todo tests', t => {
  465. t.plan(1);
  466. return promiseEnd(new Runner({match: ['*oo']}), runner => {
  467. runner.on('stateChange', evt => {
  468. if (evt.type === 'selected-test' && evt.todo) {
  469. t.pass();
  470. }
  471. });
  472. runner.chain.todo('moo');
  473. runner.chain.todo('oom');
  474. });
  475. });
  476. test('macros: Additional args will be spread as additional args on implementation function', t => {
  477. t.plan(3);
  478. return promiseEnd(new Runner(), runner => {
  479. runner.on('stateChange', evt => {
  480. if (evt.type === 'test-passed') {
  481. t.pass();
  482. }
  483. });
  484. runner.chain.before(function (a) {
  485. t.deepEqual(slice.call(arguments, 1), ['foo', 'bar']);
  486. a.pass();
  487. }, 'foo', 'bar');
  488. runner.chain('test1', function (a) {
  489. t.deepEqual(slice.call(arguments, 1), ['foo', 'bar']);
  490. a.pass();
  491. }, 'foo', 'bar');
  492. });
  493. });
  494. test('macros: Customize test names attaching a `title` function', t => {
  495. t.plan(6);
  496. const expectedTitles = [
  497. 'defaultA',
  498. 'suppliedB',
  499. 'defaultC'
  500. ];
  501. const expectedArgs = [
  502. ['A'],
  503. ['B'],
  504. ['C']
  505. ];
  506. function macroFn(avaT) {
  507. t.deepEqual(slice.call(arguments, 1), expectedArgs.shift());
  508. avaT.pass();
  509. }
  510. macroFn.title = (title, firstArg) => (title || 'default') + firstArg;
  511. return promiseEnd(new Runner(), runner => {
  512. runner.on('stateChange', evt => {
  513. if (evt.type === 'declared-test') {
  514. t.is(evt.title, expectedTitles.shift());
  515. }
  516. });
  517. runner.chain(macroFn, 'A');
  518. runner.chain('supplied', macroFn, 'B');
  519. runner.chain(macroFn, 'C');
  520. });
  521. });
  522. test('macros: test titles must be strings', t => {
  523. t.plan(1);
  524. return promiseEnd(new Runner(), runner => {
  525. t.throws(() => {
  526. const macro = t => t.pass();
  527. macro.title = () => [];
  528. runner.chain(macro);
  529. }, new TypeError('Test & hook titles must be strings'));
  530. });
  531. });
  532. test('macros: hook titles must be strings', t => {
  533. t.plan(1);
  534. return promiseEnd(new Runner(), runner => {
  535. t.throws(() => {
  536. const macro = t => t.pass();
  537. macro.title = () => [];
  538. runner.chain.before(macro);
  539. }, new TypeError('Test & hook titles must be strings'));
  540. });
  541. });
  542. test('match applies to macros', t => {
  543. t.plan(1);
  544. function macroFn(avaT) {
  545. avaT.pass();
  546. }
  547. macroFn.title = (title, firstArg) => `${firstArg}bar`;
  548. return promiseEnd(new Runner({match: ['foobar']}), runner => {
  549. runner.on('stateChange', evt => {
  550. if (evt.type === 'test-passed') {
  551. t.is(evt.title, 'foobar');
  552. }
  553. });
  554. runner.chain(macroFn, 'foo');
  555. runner.chain(macroFn, 'bar');
  556. });
  557. });
  558. test('arrays of macros', t => {
  559. const expectedArgsA = [
  560. ['A'],
  561. ['B'],
  562. ['C']
  563. ];
  564. const expectedArgsB = [
  565. ['A'],
  566. ['B'],
  567. ['D']
  568. ];
  569. function macroFnA(a) {
  570. t.deepEqual(slice.call(arguments, 1), expectedArgsA.shift());
  571. a.pass();
  572. }
  573. macroFnA.title = prefix => `${prefix}.A`;
  574. function macroFnB(a) {
  575. t.deepEqual(slice.call(arguments, 1), expectedArgsB.shift());
  576. a.pass();
  577. }
  578. macroFnB.title = prefix => `${prefix}.B`;
  579. return promiseEnd(new Runner(), runner => {
  580. runner.on('stateChange', evt => {
  581. if (evt.type === 'test-passed') {
  582. t.pass();
  583. }
  584. });
  585. runner.chain('A', [macroFnA, macroFnB], 'A');
  586. runner.chain('B', [macroFnA, macroFnB], 'B');
  587. runner.chain('C', macroFnA, 'C');
  588. runner.chain('D', macroFnB, 'D');
  589. }).then(() => {
  590. t.is(expectedArgsA.length, 0);
  591. t.is(expectedArgsB.length, 0);
  592. });
  593. });
  594. test('match applies to arrays of macros', t => {
  595. t.plan(1);
  596. // Foo
  597. function fooMacro(a) {
  598. t.fail();
  599. a.pass();
  600. }
  601. fooMacro.title = (title, firstArg) => `${firstArg}foo`;
  602. function barMacro(avaT) {
  603. avaT.pass();
  604. }
  605. barMacro.title = (title, firstArg) => `${firstArg}bar`;
  606. function bazMacro(a) {
  607. t.fail();
  608. a.pass();
  609. }
  610. bazMacro.title = (title, firstArg) => `${firstArg}baz`;
  611. return promiseEnd(new Runner({match: ['foobar']}), runner => {
  612. runner.on('stateChange', evt => {
  613. if (evt.type === 'test-passed') {
  614. t.is(evt.title, 'foobar');
  615. }
  616. });
  617. runner.chain([fooMacro, barMacro, bazMacro], 'foo');
  618. runner.chain([fooMacro, barMacro, bazMacro], 'bar');
  619. });
  620. });
  621. test('silently skips other tests when .only is used', t => {
  622. t.plan(1);
  623. return promiseEnd(new Runner(), runner => {
  624. runner.on('stateChange', evt => {
  625. if (evt.type === 'test-passed') {
  626. t.pass();
  627. }
  628. });
  629. runner.chain('skip me', a => a.pass());
  630. runner.chain.serial('skip me too', a => a.pass());
  631. runner.chain.only('only me', a => a.pass());
  632. });
  633. });
  634. test('subsequent always hooks are run even if earlier always hooks fail', t => {
  635. t.plan(3);
  636. return promiseEnd(new Runner(), runner => {
  637. runner.chain('test', a => a.pass());
  638. runner.chain.serial.after.always(a => {
  639. t.pass();
  640. a.fail();
  641. });
  642. runner.chain.serial.after.always(a => {
  643. t.pass();
  644. a.fail();
  645. });
  646. runner.chain.after.always(a => {
  647. t.pass();
  648. a.fail();
  649. });
  650. });
  651. });
  652. test('hooks run concurrently, but can be serialized', t => {
  653. t.plan(7);
  654. let activeCount = 0;
  655. return promiseEnd(new Runner(), runner => {
  656. runner.chain('test', a => a.pass());
  657. runner.chain.before(() => {
  658. t.is(activeCount, 0);
  659. activeCount++;
  660. return new Promise(resolve => setTimeout(resolve, 20)).then(() => {
  661. activeCount--;
  662. });
  663. });
  664. runner.chain.before(() => {
  665. t.is(activeCount, 1);
  666. activeCount++;
  667. return new Promise(resolve => setTimeout(resolve, 10)).then(() => {
  668. activeCount--;
  669. });
  670. });
  671. runner.chain.serial.before(() => {
  672. t.is(activeCount, 0);
  673. activeCount++;
  674. return new Promise(resolve => setTimeout(resolve, 10)).then(() => {
  675. activeCount--;
  676. });
  677. });
  678. runner.chain.before(() => {
  679. t.is(activeCount, 0);
  680. activeCount++;
  681. return new Promise(resolve => setTimeout(resolve, 20)).then(() => {
  682. activeCount--;
  683. });
  684. });
  685. runner.chain.before(() => {
  686. t.is(activeCount, 1);
  687. activeCount++;
  688. return new Promise(resolve => setTimeout(resolve, 10)).then(() => {
  689. activeCount--;
  690. });
  691. });
  692. runner.chain.serial.before(() => {
  693. t.is(activeCount, 0);
  694. activeCount++;
  695. return new Promise(resolve => setTimeout(resolve, 10)).then(() => {
  696. activeCount--;
  697. });
  698. });
  699. runner.chain.serial.before(() => {
  700. t.is(activeCount, 0);
  701. });
  702. });
  703. });