lan*_*ndo 5 angular cypress cypress-cucumber-preprocessor
我正在与Angular应用程序cypress 9.3.1一起使用。@cypress/code-coverage 3.9.12cypress-cucumber-preprocessor 4.3.113.0.1
我的测试运行良好,并且还收集了代码覆盖率,但在 afterAll 挂钩中我收到错误TypeError: elm[aelFn] is not a function。我不知道它是从哪里来的。
我正在使用ngx-build-plus 13.0.1extraWebpackConf 来为 Angular 应用程序提供服务,但即使我使用“常规”,@angular-devkit/build-angular:dev-server错误消息也会出现在我的测试结束时(然后代码不会被检测)。
我的plugin/index.ts:
const browserify = require('@cypress/browserify-preprocessor');
const cucumber = require('cypress-cucumber-preprocessor').default;
const path = require('path');
export default (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions): Cypress.PluginConfigOptions => {
// code coverage plugin
require('@cypress/code-coverage/task')(on, config);
// cucumber plugin
const options = {
...browserify.defaultOptions,
typescript: path.resolve('node_modules/typescript'),
};
on('file:preprocessor', cucumber(options));
return config;
};
Run Code Online (Sandbox Code Playgroud)
您可以看到下面的错误截图:
[![elm[aelFn] 不是函数1](https://i.stack.imgur.com/jS6Fn.png)
编辑:即使我删除赛普拉斯代码覆盖插件,错误仍然发生。
我无法解决这个问题,但是当我发现错误时,它至少会显示更少的错误消息
Cypress.on('uncaught:exception', (e) => {
if (e.message.includes('elm[aelFn] is not a function')) {
// we expected this error, so let's ignore it
// and let the test continue
return false;
}
// on any other error message the test fails
});
Run Code Online (Sandbox Code Playgroud)