diff --git a/README.md b/README.md index 7eba3e0..9e82910 100755 --- a/README.md +++ b/README.md @@ -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 @@ -75,7 +75,7 @@ module.exports = (on, config) => { } }; - require('cypress-terminal-report').installPlugin(on, options); + require('cypress-terminal-report/src/installLogsCollector')(on, options); // ... }; ``` @@ -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. diff --git a/index.js b/index.js index 02896f1..4486473 100755 --- a/index.js +++ b/index.js @@ -7,6 +7,7 @@ module.exports = { * * Needs to be added to plugins file. * + * @deprecated * @param {Function} on * Cypress event listen handler. * @param {object} options @@ -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'. diff --git a/src/installLogsCollector.js b/src/installLogsCollector.js index 00764c6..9dc41eb 100755 --- a/src/installLogsCollector.js +++ b/src/installLogsCollector.js @@ -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 = []; }); diff --git a/test/cypress/plugins/index.js b/test/cypress/plugins/index.js old mode 100644 new mode 100755 index 4f8f01d..88ab39c --- a/test/cypress/plugins/index.js +++ b/test/cypress/plugins/index.js @@ -14,5 +14,5 @@ module.exports = (on, config) => { }; } - require('../../../index').installPlugin(on, options); + require('../../../src/installLogsPrinter')(on, options); }; diff --git a/test/cypress/support/index.js b/test/cypress/support/index.js index 73842b4..e37693a 100755 --- a/test/cypress/support/index.js +++ b/test/cypress/support/index.js @@ -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() { diff --git a/test/test.js b/test/test.js index 8802bf1..25aaec5 100755 --- a/test/test.js +++ b/test/test.js @@ -140,8 +140,8 @@ describe('cypress-terminal-report', () => { await runTest(commandBase(['printHeaderData=1', 'printRequestData=1'], [`xhrTypes.spec.js`]), (error, stdout, stderr) => { expect(stdout).to.contain(`Status: 403\n${PADDING}Request headers: {\n${PADDING} "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",\n`); expect(stdout).to.contain(`\n${PADDING} "test-header": "data",\n${PADDING} "vary": "Accept-Encoding"\n${PADDING}}\n${PADDING}Response body: {\n${PADDING} "key": "data"\n${PADDING}}\n`); - expect(stdout).to.contain(`POST http://www.mocky.io/v2/5ec993803000009700a6ce1f\n${PADDING}Status: 400\n${PADDING}Request headers: {\n${PADDING} "token": "test"\n${PADDING}}\n${PADDING}Request body: {\n${PADDING} "testitem": "ha"\n${PADDING}}\n${PADDING}Response headers: {\n${PADDING} "server": "Cowboy",\n${PADDING} "connection": "keep-alive",\n${PADDING} "vary": "Accept-Encoding",\n${PADDING} "access-control-allow-origin": "*",\n`); - expect(stdout).to.contain(`\n${PADDING} "content-type": "application/json",\n${PADDING} "content-length": "96",\n${PADDING} "via": "1.1 vegur"\n${PADDING}}\n${PADDING}Response body: {\n${PADDING} "status": "Wrong!",\n${PADDING} "data": {\n${PADDING} "corpo": "corpo da resposta",\n${PADDING} "titulo": "titulo da resposta"\n${PADDING} }\n${PADDING}}\n`); + expect(stdout).to.contain(`POST http://www.mocky.io/v2/5ec993803000009700a6ce1f\n${PADDING}Status: 400\n${PADDING}Request headers: {\n${PADDING} "token": "test"\n${PADDING}}\n${PADDING}Request body: {\n${PADDING} "testitem": "ha"\n${PADDING}}\n${PADDING}Response headers: {\n${PADDING} "vary": "Accept-Encoding",\n${PADDING} "access-control-allow-origin": "*",\n${PADDING} "content-type": "application/json; charset=UTF-8",`); + expect(stdout).to.contain(`\n${PADDING}Response body: {\n${PADDING} "status": "Wrong!",\n${PADDING} "data": {\n${PADDING} "corpo": "corpo da resposta",\n${PADDING} "titulo": "titulo da resposta"\n${PADDING} }\n${PADDING}}\n`); }); }).timeout(60000);