为什么不将包含在React模块上的模拟事件触发为依赖项?

时间:2019-09-05 21:44:10

标签: reactjs testing events dependencies

我正在将一个大型React项目(https://github.com/bootstrapworld/codemirror-blocks)重构为模块,一个核心库,该核心库由其他模块(例如-https://github.com/bootstrapworld/pyret-blocks)包含和扩展。

我在整体仓库中有一个大型测试套件,可以通过。在重构设置中,当这些相同的测试包含模拟的(通过React-TestUtils)按键事件时,它们将失败。

一些调试表明,核心库根本没有收到这些事件。事件处理程序根本根本不会被调用。但是,运行实际的应用程序效果很好,所有真实事件都可以正确处理。

没有任何错误消息-Karma测试只是失败,没有输出(Karma测试失败除外):

HeadlessChrome 76.0.3809 (Mac OS X 10.14.6) functions with return annotations fun g() -> Number: 2 * 4 end should activate function name, arguments, return annotation and body FAILED
    Error: Expected fun g() -> Number: 2 * 4 end not to be fun g() -> Number: 2 * 4 end. Tip: To check for deep equality, use .toEqual() instead of .toBe().
        at <Jasmine>
        at UserContext.<anonymous> (webpack:///spec/languages/pyret/Navigation-test.js:334:39 <- spec/index.js:42196:39)
        at <Jasmine>
        at asyncGeneratorStep (spec/index.js:41880:103)
    Error: Expected fun g() -> Number: 2 * 4 end to be g. Tip: To check for deep equality, use .toEqual() instead of .toBe().
        at <Jasmine>
        at UserContext.<anonymous> (webpack:///spec/languages/pyret/Navigation-test.js:335:35 <- spec/index.js:42197:35)
        at <Jasmine>
        at asyncGeneratorStep (spec/index.js:41880:103)
    Error: Expected fun g() -> Number: 2 * 4 end not to be fun g() -> Number: 2 * 4 end. Tip: To check for deep equality, use .toEqual() instead of .toBe().
        at <Jasmine>
        at UserContext.<anonymous> (webpack:///spec/languages/pyret/Navigation-test.js:359:39 <- spec/index.js:42219:39)
        at <Jasmine>
        at asyncGeneratorStep (spec/index.js:41880:103)
    Error: Expected fun g() -> Number: 2 * 4 end to be Number. Tip: To check for deep equality, use .toEqual() instead of .toBe().
        at <Jasmine>
        at UserContext.<anonymous> (webpack:///spec/languages/pyret/Navigation-test.js:361:35 <- spec/index.js:42221:35)
        at <Jasmine>
        at asyncGeneratorStep (spec/index.js:41880:103)
    Error: Expected fun g() -> Number: 2 * 4 end not to be fun g() -> Number: 2 * 4 end. Tip: To check for deep equality, use .toEqual() instead of .toBe().
        at <Jasmine>
        at UserContext.<anonymous> (webpack:///spec/languages/pyret/Navigation-test.js:371:39 <- spec/index.js:42229:39)
        at <Jasmine>
        at asyncGeneratorStep (spec/index.js:41880:103)
    Error: Expected fun g() -> Number: 2 * 4 end to be 2 * 4. Tip: To check for deep equality, use .toEqual() instead of .toBe().
        at <Jasmine>
        at UserContext.<anonymous> (webpack:///spec/languages/pyret/Navigation-test.js:374:35 <- spec/index.js:42232:35)
        at <Jasmine>
        at asyncGeneratorStep (spec/index.js:41880:103)

0 个答案:

没有答案