类:TestsStream


🌐 Class: TestsStream

成功调用 run() 方法将返回一个新的 <TestsStream> 对象,流式传输一系列表示测试执行的事件。TestsStream 将按照测试定义的顺序触发事件

🌐 A successful call to run() method will return a new <TestsStream> object, streaming a series of events representing the execution of the tests. TestsStream will emit events, in the order of the tests definition

有些事件保证按照测试定义的顺序触发,而有些事件则按照测试执行的顺序触发。

🌐 Some of the events are guaranteed to be emitted in the same order as the tests are defined, while others are emitted in the order that the tests execute.

下面的表格按范围总结了所有事件。

🌐 The following tables summarize all events by scope.

测试的范围事件在每个测试或测试套件中只会触发一次。它们中的大多数成对出现:一个是声明顺序事件,会缓冲以确保事件按测试定义的顺序触发;另一个或多个是对应的执行顺序事件,会在测试执行时立即触发。

🌐 Test scoped events are emitted once per test or suite. Most of them come in pairs: a declaration ordered event, buffered so that events are emitted in the same order as the tests are defined, and one or more corresponding execution ordered events, emitted immediately as the tests execute.

声明有序(缓冲)执行有序(立即)
'test:start''test:enqueue' 接着 'test:dequeue'
'test:pass''test:complete'details.passedtrue
'test:fail''test:complete'details.passedfalse
'test:plan'
'test:diagnostic'
'test:log'

'test:log' 只会按顺序执行:它是 'test:diagnostic' 缓冲报告的实时对应。

文件作用域和全局事件总是会按执行顺序立即触发。

🌐 File scoped and global events are always emitted immediately, in execution order.

文件作用域事件每个测试文件只会触发一次:

🌐 File scoped events are emitted once per test file:

事件备注
'test:stderr'只有在传入 --test 标志时才会触发。
'test:stdout'只有在传入 --test 标志时才会触发。
'test:summary'每个文件在使用进程隔离时才会触发。

全局事件在每次测试运行时只会触发一次:

🌐 Global events are emitted once per test run:

事件备注
'test:summary'最终累计总结。
'test:coverage'仅当启用代码覆盖率时。
'test:interrupted'仅当运行接收到 SIGINT 时。
'test:watch:drained'仅限观察模式。
'test:watch:restarted'仅限观察模式。

根测试还会在运行结束时发出'test:plan''test:diagnostic'事件,以报告运行级别的总数。

🌐 The root test also emits 'test:plan' and 'test:diagnostic' events at the end of the run to report run level totals.