Ole*_*Ole 6 javascript node.js typescript jestjs codesandbox
在此代码沙箱中执行以下测试:
import { of } from "rxjs";
import { map } from "rxjs/operators";
const source = of("World");
test("It should fail", () => {
source.subscribe(x => expect(x).toContain("NOTHING"));
});
Run Code Online (Sandbox Code Playgroud)
尽管预期落空,但 Jest 仍将其报告为通过。想法?
rxjs 可观察量是异步的。查看此页面以帮助测试异步代码
您想添加完成参数,如下所示 ->
test("It should fail", done => {
source.subscribe(
x => {
expect(x).toContain("NOTHING")
done();
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1943 次 |
| 最近记录: |