diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c2e9ea6..32d2d94 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,10 @@ name: Test on: push: + branches: + - '**' + tags-ignore: + - '*' paths-ignore: - '**.md' workflow_dispatch: diff --git a/README.md b/README.md index 14d6916..c069e0a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Cypress XML Reporter -A JUnit XML reporter for Cypress that includes screenshots, videos, and logs. +A JUnit XML reporter for Cypress that includes **screenshots**, **videos**, and **logs** on test failures. ![CI](https://github.com/testspace-com/cypress-xml-reporter/actions/workflows/test.yml/badge.svg) [![npm](https://img.shields.io/npm/v/cypress-xml-reporter.svg?style=flat-square)](http://www.npmjs.com/package/cypress-xml-reporter) @@ -8,7 +8,7 @@ This reporter works with [Testspace](https://testspace.com) to publish CI test r 1. Captured screenshot of a test failure 2. Captured video for a suite with one or more failing tests -3. Logs generated using the [cypress terminal reporter](https://www.npmjs.com/package/cypress-terminal-report) +3. Logs generated using the [cypress terminal reporter](https://github.com/archfz/cypress-terminal-report) ## Installation @@ -20,6 +20,7 @@ npm install cypress-xml-reporter --save-dev Register the *plugin* in `cypress.config.js`: ``` module.exports = defineConfig({ + video: true, // Cypress v13.x defaults to false e2e: { setupNodeEvents(on, config) { require('cypress-xml-reporter/src/plugin') (on); @@ -28,6 +29,8 @@ module.exports = defineConfig({ }); ``` +Note that Cypress [v13.x](https://docs.cypress.io/guides/references/changelog#13-0-0) defaults the `video` option to `false`. This option requires to be `true` to capture videos for test failures. + ## Usage Run Cypress with `cypress-xml-reporter`: @@ -47,6 +50,8 @@ $ cypress run --reporter cypress_xml_reporter --reporter-options "resultsFolder= Or using `cypress.config.js`: ``` module.exports = defineConfig({ + video: true, // Cypress v13.x defaults to false + reporter: 'cypress-xml-reporter', reporterOptions: { resultsFolder: './path/location' }, @@ -59,12 +64,12 @@ module.exports = defineConfig({ ``` ## Terminal Logging -To capture terminal output as log files the [Cypress terminal report](https://www.npmjs.com/package/cypress-terminal-report) package is supported: +To capture terminal output as log files the [Cypress terminal report](https://github.com/archfz/cypress-terminal-report) package is supported: ``` npm install cypress-terminal-report --save-dev ``` -The package is required to be configured for [log specs in separate files](https://github.com/archfz/cypress-terminal-report#logging-to-files), setting the **type** format as `txt`. +The package is required to be configured for [log specs in separate files](https://github.com/archfz/cypress-terminal-report#logging-to-files), setting the **type** format as `txt`. And pass in the defined options (i.e. *logsOptions*) to the reporter plugin: ``` setupNodeEvents(on, config) { @@ -75,10 +80,8 @@ setupNodeEvents(on, config) { } }; require('cypress-terminal-report/src/installLogsPrinter')(on, logsOptions); + require('cypress-xml-reporter/src/plugin') (on, logsOptions); } ``` -And pass in the defined options (i.e *logsOptions*) to the reporter plugin: -``` - require('cypress-xml-reporter/src/plugin') (on, logsOptions); -``` \ No newline at end of file +Note that the terminal report requires an extra [installation](https://github.com/archfz/cypress-terminal-report#install) step to **register the log collector**. \ No newline at end of file diff --git a/package.json b/package.json index 2a80335..59f24e9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cypress-xml-reporter", - "version": "1.0.0", + "version": "1.0.1", "description": "A JUnit XML reporter for Cypress that includes screenshots, videos, and logs.", "main": "src/reporter.js", "scripts": { diff --git a/src/reporter.js b/src/reporter.js index 5058b3c..d35fa32 100644 --- a/src/reporter.js +++ b/src/reporter.js @@ -123,7 +123,7 @@ function createTestRecord(test, specRelativePath) { case 'failed': record['failure'] = {$: {message: test.err.message, type: test.err.name}, _: test.err.stack}; { - const UNSAFE_REGEX = /[^ A-Za-z0-9._-]/g; + const UNSAFE_REGEX = /[^ A-Za-z0-9.()_-]/g; let imageBasename = testFullName.replaceAll(UNSAFE_REGEX, '').substring(0, 242)+' (failed).png'; let imageFile = path.join(config.screenshotsFolder, specRelativePath, imageBasename); if (fs.existsSync(imageFile)) {