bahmutov / bahmutov/cypress-angular-unit-test

Could you provide more info on how to configure angular.json to do code coverage without using ngx-build-plus

Open
#552 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
160
Forks
32
PR merge metrics
No merged PRs in 30d

Description

Using Cypress 8.1 and cypress component test runner.
plugin config:
```
import * as webpackConfig from './webpack.config';
import * as allureWriter from '@shelex/cypress-allure-plugin/writer';
module.exports = (on: any, config: any) => {
const { startDevServer } = require('@cypress/webpack-dev-server');
on('dev-server:start', (options) => startDevServer({ options, webpackConfig }));
require('@cypress/code-coverage/task')(on, config);
allureWriter(on, config);
return config;
};
```
support/index.js- added this line

import '@cypress/code-coverage/support';

webpack.config.js contains:
```
{
test: /\.(js|ts)$/,
loader: 'istanbul-instrumenter-loader',
options: { esModules: true },
enforce: 'post',
include: path.join(__dirname, '../..', 'src'),
exclude: [
/\.(e2e|spec)\.ts$/,
/node_modules/,
/(ngfactory|ngstyle)\.js/,
],
},

```
Also, i have coverage.webpack.js which contains:
```

module.exports = {
module: {
rules: [
{
test: /\.(js|ts)$/,
loader: 'istanbul-instrumenter-loader',
options: { esModules: true },
enforce: 'post',
include: require('path').join(__dirname, '..', 'src'),
exclude: [ /\.(e2e|spec)\.ts$/, /node_modules/, /(ngfactory|ngstyle)\.js/ ],
},
],
},
};
```
![dialog](https://user-images.githubusercontent.com/22374311/128652373-931a942b-6725-43ce-b084-f27e9178fdce.jpg)

Without using ngx-build-plus, how to serve anguar for code coverage.

Contributor guide

No contributing guide indexed for this repository

Research direction

Review angular.json alongside the provided Cypress plugin setup, support/index.js, webpack.config.js, and coverage.webpack.js. Document a working way to serve Angular with code coverage without ngx-build-plus, using the Cypress component test runner configuration as the reference and making the expected coverage result clear.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, cypress, typescript, webpack
Domain
build-system, documentation, frontend, testing
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.