angular.mock.module is not a function

问题: Jest27中报错 angular.mock.module is not a function

环境中使用的各个库的版本 AngularJs1.5.8; Jest27.0.6

1. AngularJs官方文档中指出:

    This function is declared ONLY WHEN running tests with jasmine or mocha

    查看源码发现:

          

    使用不同版本的jest,然后在测试文件中分别打印window对象,Jest26版本window对象中有jasmine对象,而Jest27版本中打印信息中无jasmine对象

2. Jest和Jasmine到底是什么关系呢?

    在Jest官网,有关jest对AngularJs框架的支持,给出的参考信息列表中,有篇博客Running AngularJs Tests with Jest中提到了二者的关系:

   Jest uses a modified version of Jasmine as its test runner

    最开始使用的Jest版本是21,后升级到26.6.3也是可以正常运行的, 但升级到27版本之后不可用
    在Jest Recent Posts中有说明:

    Jest 27 will ship with a new teste runner "jest-circus" and the Node.js environment by default.
    jest-jasmine2 and jest-environment-jsdom will still be bundled so users can keep using them by changing one-line each in the configuration.

本测试用例中Jest相关配置在package.json文件中:

 

    另外还提到了关于Jest28中有关jasmine的一些计划:

    Jest 28 will remove jest-jasmine2 and jest-environment-jsdom from the default distribution of Jest. The packages will still be actively maintained as part of the Jest project and be published separately. Users will need to install these packages to use them.


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值