我有一个非常烦人的情况,我有一个单独运行的测试文件:
NODE_ENV=test mocha --require @babel/polyfill --require @babel/register --require mocha-setup.js --require ignore-styles --timeout 10000 './src/tests/MyComponent.test.js'
工作正常并通过所有测试。
但是当作为套件的一部分运行时:
NODE_ENV=test mocha --require @babel/polyfill --require @babel/register --require mocha-setup.js --require ignore-styles --timeout 10000 './src/**/*.test.js'
我失败了。主要错误消息是:
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
我唯一能想到的就是摩卡咖啡将其构建为错误的。有人来过这个吗?