Skip to content

Commit

Permalink
Fixed issue with webpack and tests. #32 #31
Browse files Browse the repository at this point in the history
  • Loading branch information
archfz committed Jun 8, 2020
1 parent e335710 commit 3b5f015
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ to your CI runner and check the pipeline logs there.
2. Register the output plugin in `cypress/plugins/index.js`
```js
module.exports = (on) => {
require('cypress-terminal-report').installPlugin(on);
require('cypress-terminal-report/src/installLogsCollector')(on);
};
```
3. Register the log collector support in `cypress/support/index.js`
```js
require('cypress-terminal-report').installSupport();
require('cypress-terminal-report/src/installLogsPrinter')();
```

## Options
Expand Down Expand Up @@ -75,7 +75,7 @@ module.exports = (on, config) => {
}
};
require('cypress-terminal-report').installPlugin(on, options);
require('cypress-terminal-report/src/installLogsCollector')(on, options);
// ...
};
```
Expand Down Expand Up @@ -139,6 +139,11 @@ directory. You should add `it.only` to the test case you are working on to speed
## Release Notes
- Fixed issue with webpack compatibility caused by native includes getting in compilation files. For this please revise
the installation documentation and change the requires for the install of this plugin. Deprecated require by index. [issue](https://github.com/archfz/cypress-terminal-report/issues/32)
- Fixed issue with logsChainId not being reset and causing test failures and potentially live failures with error
'Cannot set property '2' of undefined'. [issue](https://github.com/archfz/cypress-terminal-report/issues/31)
#### 1.3.1
- Added creation of output path for outputTarget files if directory does not exist.
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
*
* Needs to be added to plugins file.
*
* @deprecated
* @param {Function} on
* Cypress event listen handler.
* @param {object} options
Expand All @@ -23,6 +24,7 @@ module.exports = {
*
* Needs to be added to support file.
*
* @deprecated
* @param {object} config
* Options for collection logs:
* - printLogs?: string; Default: 'onFail'. When to print logs, possible values: 'always', 'onFail'.
Expand Down
3 changes: 2 additions & 1 deletion src/installLogsCollector.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ function installLogsCollector(config = {}) {
}

Cypress.on('log:changed', options => {
if (logsChainId[options.id] && options.state === 'failed') {
if ( options.state === 'failed' && logsChainId[options.id] && logs[logsChainId[options.id]]) {
logs[logsChainId[options.id]][2] = CONSTANTS.SEVERITY.ERROR;
}
});

Cypress.mocha.getRunner().on('test', () => {
logsChainId = {};
logs = [];
});

Expand Down
2 changes: 1 addition & 1 deletion test/cypress/plugins/index.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ module.exports = (on, config) => {
};
}

require('../../../index').installPlugin(on, options);
require('../../../src/installLogsPrinter')(on, options);
};
5 changes: 4 additions & 1 deletion test/cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ if (env.printRequestData == '1') {
config.xhr = config.xhr || {};
config.xhr.printRequestData = true;
}
if (env.filterOutCyCommand == '1') {
config.filterLog = ([type]) => type !== 'cy:command';
}

require('../../../index').installSupport(config);
require('../../../src/installLogsCollector')(config);

enableFetchWorkaround();
function enableFetchWorkaround() {
Expand Down

0 comments on commit 3b5f015

Please sign in to comment.