ERRORinworker-7d0pvWarcI3nxcmEFPPS9.jsfromTerserTypeError:_jestWorker.defaultisnotaconstructoratgetWorker(/Users/***/Projects/oss/next-pwa/examples/custom-worker/node_modules/next/dist/compiled/webpack/bundle5.js:28270:9)at/Users/***/Projects/oss/next-pwa/examples/custom-worker/node_modules/nex...
import nodeModulePackage from 'nodeModulePackage'; 所以我需要将其模拟为默认值,因为我不断收到错误(0, _blah.default) is not a function.。 我的解决方案是: jest.mock('nodeModulePackage', () => jest.fn(() => {})); 在我的例子中,我只需要覆盖函数并让它返回一个空对象。 如果您需要在该节...
这是行不通的;所有测试都抛出TypeError: _soundPlayer2.default is not a constructor。 正在测试的类:sound-player-consumer.js import SoundPlayer from './sound-player'; // Default import export default class SoundPlayerConsumer { constructor() { this.soundPlayer = new SoundPlayer(); //TypeError: _sou...
` })); 在我们的单元测试中,我们希望检查是否使用正确的参数调用了createLogger。我们最初只是尝试使用jest.mock('winston),但jest抱怨TypeError: transports.Console is not a constructor。但是我们的测试失败了,如 浏览8提问于2019-01-22得票数 1 1回答 Jest单元测试快车-验证器 、、 我正在使用Jest单元...
前端开发人员更多地是设计驱动的,而后端开发人员则更注重数据。这通常会导致潜在的整合差距,其中一个...
TypeError: ourCode is not a function CommonJS 不理解 require 进来的 ES Modules。这很容易解决,通过 export default 导出函数,require 模块的时候添加 .default // externalModule.js const ourCode = () => 'result'; export default ourCode; // testSubject.js const ourCode = require('./externalMod...
TypeError: result.message is not a function Hi, From what I see in chain.js, the JestAssertionError constructor considers result.message as a function when its actually a string. At some point, Jest must have changed and started calling the message factory to throw the message string instead...
constructor: API, getFrames }; module.exports = new API(); 我模仿getFrame函数返回一个由3个对象组成的数组,但在运行测试用例时,它返回了undefined。显示以下错误: TypeError: Cannot read property 'filter' of undefined 我嘲笑这是正确的吗? 并非一次所有文件:...
我成功地做了一个这样的测试 这就是函数 import admin from 'firebase-admin'admin.initializeApp({ credential: admin.credential.cert(credentials),})const createClosure = (admin) => { if (!admin) { throw new Error(Errors.FIREBASE_ADMIN_SDK_NOT_PROVIDED) } return (data) => { if ( data && ...
[jest-runtime] Forward wrapperLength to the Script constructor as columnOffset for accurate debugging (#14148) [jest-runtime] Guard _isMockFunction access with in (#14188) [jest-snapshot] Fix a potential bug when not using prettier and improve performance (#14036) [@jest/transform] Do not...