Code Monkey home page Code Monkey logo

cypress-terminal-report's People

Contributors

alexguironnetrte avatar andrew-blomquist-6 avatar archfz avatar bengry avatar bjowes avatar bvandercar-vt avatar christine-pinto avatar dependabot[bot] avatar drebrez avatar erik-outreach avatar flevi29 avatar jhepam avatar jmoses avatar josh68 avatar matmannion avatar peruukki avatar reynoldsdj avatar rinero-bigpanda avatar tebeco avatar wopian avatar zentby avatar zhex900 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cypress-terminal-report's Issues

ReferenceError: Cypress is not defined

I tried adding this plugin to my Cypress project after discovering console.log did not print as expected, following the instructions in the README on latest version of Cypress (4.8.0), and I get this error when trying to run tests:

We invoked the function exported by `/root/project/web-integration-tests/cypress/plugins/index.js`, but it threw an error.

 ReferenceError: Cypress is not defined
    at collectBrowserConsoleLogs (/root/project/web-integration-tests/node_modules/cypress-terminal-report/src/installLogsCollector.js:147:3)
    at installLogsCollector (/root/project/web-integration-tests/node_modules/cypress-terminal-report/src/installLogsCollector.js:45:3)
    at module.exports (/root/project/web-integration-tests/cypress/plugins/index.js:25:62)
    at /root/.cache/Cypress/4.3.0/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js:75:12
    at tryCatcher (/root/.cache/Cypress/4.3.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/root/.cache/Cypress/4.3.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/method.js:39:29)
    at load (/root/.cache/Cypress/4.3.0/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js:72:7)
    at EventEmitter.<anonymous> (/root/.cache/Cypress/4.3.0/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js:196:5)
    at EventEmitter.emit (events.js:210:5)
    at process.<anonymous> (/root/.cache/Cypress/4.3.0/Cypress/resources/app/packages/server/lib/plugins/util.js:25:29)
    at process.emit (events.js:210:5)
    at emit (internal/child_process.js:876:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)

Feature: print each spec to separate file

Given that we have two specs, e,g,

myFirstTest.spec.js 
mySecondTest.spec.js

it would be nice if logs from each spec could automatically be printed to e.g:

myFirstTest.txt
mySecondTest.txt

How do I see terminal output when running in the cloud?

I've followed the steps to get this working, and then run a Cypress suite of tests in CircleCI. A test failed and I went to see the console terminal output, but couldn't figure out where it was.

The only place I could think it would be was in the Cypress Dashboard; I went to the failed spec and clicked on the "Output" icon to display the output. I got this:

image

But none of my console logs are in here.

Where should I be looking?

Support for printing objects

Currently, if object is logged to the console you see: cons:info ⓘ [object Object].

It would be great if it would display contents of the object instead. A few ideas:

  • in most cases JSON.stringify would be sufficient
  • allow to enabled on a flag to avoid spamming
  • allow to provide a custom formatter for objects

Certain cy.request errors breaks the logging

There are two scenarios in which this plugin fails to parse the result of a cy.request command. This results in the rather limited log "e.onFail is not a function", which hides the actual cy.request error also in the cypress command log.

The scenarios are:

  1. When cy.request is called with a log: false option and the request fails (non-success error code)
  2. When cy.request fails due to a network error (timeout, connection reset ...)

I am working on a PR to mitigate these scenarios and use a cy.request parsing method that works in all scenarios.

Test names aren't output when logging to file; test contexts aren't output at all

I'm using cypress-terminal-report 2.4.0 with Cypress 5.6.0 in GitLab CI, using this config:

  require('cypress-terminal-report/src/installLogsPrinter')(on, {
    printLogsToConsole: 'onFail',
    printLogsToFile: 'always',
    outputRoot: `${ config.projectRoot }/.cypress_logs/`,
    specRoot: path.relative(config.fileServerFolder, config.integrationFolder),
    outputTarget: {
      'cypress-logs|txt': 'txt',
    },
  })

and this test:

  context('when editing or creating an issue', () => {
    context('when the user is logged out', () => {
      context('when editing the issue', () => {
        it('tells the user they must log in', () => {
          // test goes here
        })
      })
    })
  })

Logs printed to file partially identify the test being run, showing the name of the test but not the names of any containing context() blocks:

tests/e2e/integration/issue_form_spec.js:
    tells the user they must log in
        cy:request (K): http://backend:3000/api/v1/rails/reset_db
                        Status: 200
                        Response body: {
                          "errors": []
                        }

But logs printed to console don't give any identification at all:

cypress_1   |   Running:  issue_form_spec.js                                                         (7 of 15)
cypress_1   |       cy:request ✔  http://backend:3000/api/v1/rails/reset_db
cypress_1   |                     Status: 200
cypress_1   |                     Response body: {
cypress_1   |                       "errors": []
cypress_1   |                     }

This makes it difficult to find which test a log relates to, unless every test starts with a cy.log() statement giving its name, which clutters the test files unnecessarily. Would it be possible to have the name of the test output to console as well as to file, and context names output as well as test names in both cases?

(Now that I think about it, it may be a difference between onFail and always rather than logging to console vs logging to file… I've also just noticed that the tick emoji has been changed to a K when outputting to file — is that intentional?)

Save output to file

Seeing the cypress log in the terminal is great - but when integrating with a CI environment it would be helpful if the output could be (easily) saved to a file. The file could then be uploaded as an attachment to the test run.

Console messages not working?

Hello! I am trying to make console.log to show in the terminal but until now I've only managed to see cy.log. Cypress is still at version 5.5.0 and I;ve set the plugin to always display.

Tried console.log both in a test and outside, in a helper file.

Show XHR responses

Currently cypress-terminal-report only shows XHR requests when they are sent and doesn't show anything related to the server responses. It would be useful to see at least the server response status codes in the logs when investigating test failures.

The Cypress UI adds the response information to the initial request message in its command log once it arrives, but I would actually rather see the responses as their own log messages, so that we see when those responses arrived during the test execution. This would be very helpful in investigating flaky tests, which are often caused by irregular timings of network requests.

To easily separate the requests from the responses, they could have different log types, e.g. cy:xhr:req and cy:xhr:res. Here's an example of how it could look when running xhrTypes.spec.js:

      cy:command ✔  visit	/commands/network-requests
      cy:command ✔  get	.network-put
      cy:command ✔  click	
      cy:xhr:req ⓘ  STUBBED PUT https://jsonplaceholder.cypress.io/comments/1
        cy:route ⚠  (putComment) PUT https://jsonplaceholder.cypress.io/comments/1
                    Status: 403
                    Response body: {
                      "key": "data"
                    }
      cy:xhr:res ⚠  403 (Forbidden) PUT https://jsonplaceholder.cypress.io/comments/1
      cy:command ✔  wait	@putComment
      cy:command ✘  get	.breaking-get

We could also include the response body, but that should be somehow limited to avoid flooding the logs, e.g. only show it for non-2xx responses (that would be also shown as warnings).

What do you think of this idea, could this funtionality be added? I could work on a PR for it. The XHR responses are sent to the log:changed listener.

cy.request show more details

Currently cy.request does not print any content of the request. It will be good to print the same details as cy.route

I tried to add this to Cypress.on('log:added', options => {

  if (options.name === 'request' && options.hookName && options.hookName === 'test') {
    options.message = options.renderProps.message;
  }

To get more information like status, response I need to wait for the promise in options to resolve. But I don't know how to do that.

If I console.log(options) the data is in consoleProps But console.log(options.consoleProps) does show the data. I guess the promise is not resolved. How do I fix this?

Newly added callback functions are not usable

If you try to use one of the new callback functions for eg. collectTestLogs or filterLog, you get the message "Additional properties not allowed". I also didn't see them added to the PluginOptions interface.

Support for custom log collector function

We are using mochawesome to generate Cypress test run reports, and I was able to include the logs from cypress-terminal-report in the report by adding support for a custom collectTestLogs function that receives each test case's logs, with this patch:

diff --git a/node_modules/cypress-terminal-report/src/installLogsCollector.js b/node_modules/cypress-terminal-report/src/installLogsCollector.js
index 5dba191..1efbe27 100755
--- a/node_modules/cypress-terminal-report/src/installLogsCollector.js
+++ b/node_modules/cypress-terminal-report/src/installLogsCollector.js
@@ -97,6 +97,9 @@ function installLogsCollector(config = {}) {
       messages: logs,
       state: this.currentTest.state
     }, {log: false});
+    if (config.collectTestLogs) {
+      config.collectTestLogs(this, logs);
+    }
   });
 
   after(function () {
@@ -119,6 +122,9 @@ function validateConfig(config) {
     throw new Error(`[cypress-terminal-report] Invalid plugin install options: ${tv4ErrorTransformer.toReadableString(result.errors)}`);
   }
 
+  if (config.collectTestLogs && typeof config.collectTestLogs !== 'function') {
+    throw new CtrError(`[cypress-terminal-report] Collect test logs option expected to be a function.`);
+  }
   if (config.filterLog && typeof config.filterLog !== 'function') {
     throw new CtrError(`[cypress-terminal-report] Filter log option expected to be a function.`);
   }
diff --git a/node_modules/cypress-terminal-report/src/installLogsCollector.schema.json b/node_modules/cypress-terminal-report/src/installLogsCollector.schema.json
index 2525c67..38aaf37 100644
--- a/node_modules/cypress-terminal-report/src/installLogsCollector.schema.json
+++ b/node_modules/cypress-terminal-report/src/installLogsCollector.schema.json
@@ -25,6 +25,9 @@
         ]
       }
     },
+    "collectTestLogs": {
+      "type": "function"
+    },
     "filterLog": {
       "type": "function"
     },

I use it like this in my Cypress support file:

const installLogsCollector = require('cypress-terminal-report/src/installLogsCollector');
const addContext = require('mochawesome/addContext');

installLogsCollector({
    collectTestLogs: (test, logs) => addContext(test, { title: 'Cypress logs', value: renderCypressLogs(logs) }),
});

Cypress.on('test:after:run', (test, runnable) => {
    if (test.state === 'failed' && runnable.context) {
        addContext({ test }, runnable.context);
    }
});

Would you be interested in supporting this kind of an option? This is neither terminal nor file output, but your library gives us the information we need (command log and browser logs), and it formats the information beautifully. 😍

Related to this, my renderCypressLogs function above is just a modified version of your logToTerminal function that returns a string instead of writing to the console (and uses less padding). In our use case it would be useful if the log message formatting function that you use was exposed so we could use it directly, but I don't know how useful that would be for others. 🙂

Potentially wrongly labeled failing command

Due to the async nature of the cypress testing flow commands can get executed after the actual failing command. We are presuming that the last registered command is the failing one so in these cases the wrong command will be labeled as the incorrect one. We should see if there is a better way to detect which commands failed.

This issue can potentially confuse people.

TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))

I have a test that is conditionally skipped like this:

describe('My test', function() {
  before(function() {
    // Skip the tests on some environments as the feature is not enabled yet.
    if (Cypress.env('MY_URL')) {
      cy.login();
    } else {
      this.skip();
    }
  });

  it('tests the thing', function() {
    ...
  });
});

This works when I don't have cypress-terminal-report. But when I add cypress-terminal-report, in for the skip case, it fails like this:

TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
Because this error occurred during a 'before all' hook we are skipping the remaining tests in the current suite: 'Jira issues in PR sidebar test'
    at $Cypress.<anonymous> (installLogsCollector.js:40)

The line from the stack trace: https://github.com/archfz/cypress-terminal-report/blob/master/src/installLogsCollector.js#L40

I think it's because in this case, logs is empty.

Error report not working properly

Hi,

Since Cypress upgrade to v4.8.0, the cypress-terminal-report v1.3.1 plugin stopped working.

Before, it showed a full report, with all the steps executed in the test.

Now it shows the following error:

CypressError: The following error originated from your test code, not from Cypress.
   > Cypress detected that you returned a promise from a command while also invoking one or more cy commands in that promise.
 The command that returned the promise was:
   > `cy.wrap()`
 The cy command you invoked inside the promise was:
   > `cy.task()`
 Because Cypress commands are already promise-like, you don't need to wrap them or return your own promise.
 Cypress will resolve your command with whatever the final Cypress command yields.
 The reason this is an error instead of a warning is because Cypress internally queues commands serially whereas Promises execute as soon as they are invoked. Attempting to reconcile this would prevent Cypress from ever resolving.
 When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.
 Because this error occurred during a `after each` hook we are skipping all of the remaining tests.

My temporary solution was to downgrade to Cypress v4.7.0.

Looking forward to hear any feedback or see any fixes.

Best regards,
Nelson

Disable verbose

The logOutputTarget function constantly logs [cypress-terminal-report] Wrote custom logs to ... into console.

It would be great if we could turn off the verbose mode (which could be enabled by default) using some option to reduce bloating the cypress terminal output.

Something like:

  require('cypress-terminal-report/src/installLogsPrinter')(on, {
        verbose: false,
        ...
    });

cons:log logs are omitted when using in conjunction with reporter plugins

First of all, thank you for the plugin and implementing the file output, great stuff (koszonjuk szepen)!

We are using cypress in conjunction with ReportPortal which is an open source test reporting and aggregation solution. We are using agent-js-cypress plugin to push the test results and logs to ReportPortal, and cypress-multi-reporters to allow generating multiple log outputs at the same time (we need agent-js-cypress for ReportPortal and mocha, mochawesome for other systems).

Problem:

  1. When using cypress-terminal-report with cypress-multi-reporters, the majority of the logs are omitted. I think all the cons:log (K): calls are not shown in the output file or in the console; only the cy:command and cy:xhr calls are there.

  2. When using cypress-terminal-report in conjunction with agent-js-cypress, the ReportPortal custom commands in the latter are not working. Reason might the that both plugins are overriding the cy.log() command?

Happy to further assist with debugging or share code snippets if necessary. Thanks in advance.

Support print request info of "cy.route()".

In my case:

cy.server()
cy.route('POST', '**/upload**').as('upload')
cy.customCommandUpload('...')
cy.wait('@upload')

Sometimes I got below error: "token is invalid", and need to check token of request header.

截屏2020-05-21上午10 34 45

I hope this plugin support print some request info, include header and payload.

support typescript

Hi, it would be nice if you could support typescript as well, knowing that cypress supports it out of the box now.

Support to output the last few logs.

In general, only output last few logs can confirm fail reason, instead of output all logs when failed.
Some case steps are very huge, too much logs are not friendly, should use some option to limit quantity.

For example, user can set option to only output last 10 command or other type logs when case failed.

printLogs: 'always' causes nothing to be printed in files

Tested on Cypress 5.0 and latest version of cypress-terminal-report.

My config looks like this:

module.exports = (on, config) => {
  require('cypress-terminal-report/src/installLogsPrinter')(on, {
    printLogs: 'always',
    outputRoot: 'cypress/logs/',
    outputTarget: {
      'testLogs.txt': 'txt',
      'testLogs.json': 'json',
    }
  });

The above causes testLogs.txt to be empty, and testLogs.json to contain:

,
,
,
,
,
{}

However, if I set it to 'onFail' or do not specify it at all, error logs are printed normally.

ctrLogMessages timing out

We added a new, fairly long running test to our test suite and we started getting a timeout on that test.

Any suggestions on how to resolve?

cy.task('ctrLogMessages') timed out after waiting 60000ms.

TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator)) when set option: "compactLogs"

plugins index.js:

require("cypress-terminal-report").installPlugin(
      on,
       {
            compactLogs: 5,
       }
    );

support index.js:

require("cypress-terminal-report").installSupport(
  {
        collectTypes: [
          "cons:error",
          "cy:log",
          "cy:xhr",
          "cy:request",
          "cy:route",
          "cy:command",
        ],
  }
);

logs:

  1) foobar
       create foobar:
     AssertionError: Timed out retrying: Expected to find content: '/^key$/' within the element: [ <span>, 95 more... ] but never did.
      at eval (http://host:port/__cypress/tests?p=cypress/support/index.js:227:18)
  at Array.forEach (<anonymous>)
      at Context.createDashboard (http://host:port/__cypress/tests?p=cypress/support/index.js:224:17)

  2) foobar
       "after each" hook for "create foobar":
     CypressError: `cy.task('ctrLogMessages')` failed with the following error:

> undefined is not iterable (cannot read property Symbol(Symbol.iterator))

Because this error occurred during a `after each` hook we are skipping all of the remaining tests.
      at http://host:port/__cypress/runner/cypress_runner.js:158198:19
      at tryCatcher (http://host:port/__cypress/runner/cypress_runner.js:10130:23)
      at Promise._settlePromiseFromHandler (http://host:port/__cypress/runner/cypress_runner.js:8065:31)
      at Promise._settlePromise (http://host:port/__cypress/runner/cypress_runner.js:8122:18)
      at Promise._settlePromise0 (http://host:port/__cypress/runner/cypress_runner.js:8167:10)
      at Promise._settlePromises (http://host:port/__cypress/runner/cypress_runner.js:8243:18)
      at _drainQueueStep (http://host:port/__cypress/runner/cypress_runner.js:4837:12)
      at _drainQueue (http://host:port/__cypress/runner/cypress_runner.js:4830:9)
      at Async.../../node_modules/bluebird/js/release/async.js.Async._drainQueues (http://host:port/__cypress/runner/cypress_runner.js:4846:5)
      at Async.drainQueues (http://host:port/__cypress/runner/cypress_runner.js:4716:14)
  From Your Spec Code:
      at Context.eval (http://host:port/__cypress/tests?p=cypress/support/index.js:2975:10)
  
  From Node.js Internals:
    TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
        at /Users/jasonzhang/Documents/code/foobar/e2e/node_modules/cypress-terminal-report/src/installLogsPrinter.js:151:20
    at Array.forEach (<anonymous>)
        at logToTerminal (/Users/jasonzhang/Documents/code/foobar/e2e/node_modules/cypress-terminal-report/src/installLogsPrinter.js:151:12)
        at ctrLogMessages (/Users/jasonzhang/Documents/code/foobar/e2e/node_modules/cypress-terminal-report/src/installLogsPrinter.js:51:7)
        at invoke (/Users/jasonzhang/Library/Caches/Cypress/4.10.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/task.js:41:14)
        at /Users/jasonzhang/Library/Caches/Cypress/4.10.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:41:14
        at tryCatcher (/Users/jasonzhang/Library/Caches/Cypress/4.10.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
        at Function.Promise.attempt.Promise.try (/Users/jasonzhang/Library/Caches/Cypress/4.10.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/method.js:39:29)
        at Object.wrapChildPromise (/Users/jasonzhang/Library/Caches/Cypress/4.10.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:40:23)
        at Object.wrap (/Users/jasonzhang/Library/Caches/Cypress/4.10.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/task.js:47:8)
        at execute (/Users/jasonzhang/Library/Caches/Cypress/4.10.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:142:12)
        at EventEmitter.<anonymous> (/Users/jasonzhang/Library/Caches/Cypress/4.10.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:235:5)
        at EventEmitter.emit (events.js:210:5)
        at process.<anonymous> (/Users/jasonzhang/Library/Caches/Cypress/4.10.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:19:22)
        at process.emit (events.js:210:5)
        at process.emit (/Users/jasonzhang/Library/Caches/Cypress/4.10.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/source-map-support/source-map-support.js:495:21)
        at emit (internal/child_process.js:876:12)
        at processTicksAndRejections (internal/process/task_queues.js:81:21)

version

Cypress: 4.10.0
cypress-terminal-report: 1.4.1

Getting error mixing `cy.request` with `cy.now`

Hello! First of all thank you for this plugin!

However, there is an error I'm stuck with. Getting this error when mixing cy.now with cy.request and cy.wrap:
image

Steps to reproduce:

it('cy.request + cy.now', function () {
  cy.wrap(true).then(() => {
    return cy
      .now('request', {
        url: `http://google.com`,
      })
      .then(($res) => cy.wrap($res, { log: false }));
  });
});

I see that the plugin overwrites request and server. Maybe it makes sense to make request and server logs configurable(turn on/off)?

BaseOutputProcessor doesn't compatible with Webpack

When working with webpack and its cypress plugin, the default webpack has target: "web", which doesn't support the native require. Thus throw exceptions:

Oops...we found an error preparing this test file:

  cypress/support/index.js

The error was:

Error: Webpack Compilation Error
./node_modules/cypress-terminal-report/src/outputProcessor/BaseOutputProcessor.js
Module not found: Error: Can't resolve 'fs' in './node_modules/cypress-terminal-report/src/outputProcessor'
resolve 'fs' in './node_modules/cypress-terminal-report/src/outputProcessor'
  Parsed request is a module
...
...
 @ ./node_modules/cypress-terminal-report/src/outputProcessor/BaseOutputProcessor.js 1:11-24
 @ ./node_modules/cypress-terminal-report/src/outputProcessor/CustomOutputProcessor.js
 @ ./node_modules/cypress-terminal-report/src/installLogsPrinter.js
 @ ./node_modules/cypress-terminal-report/index.js
 @ ./cypress/support/index.js
 @ multi ./cypress/support/index.js

webpack.config

module.exports = {
    resolve: {
        extensions: ['.ts', '.js']
    },
    module: {
        rules: [
            {
                test: /\.ts$/,
                exclude: [/node_modules/],
                use: [
                    {
                        loader: 'ts-loader',
                        options: {
                            transpileOnly: true
                        }
                    }
                ]
            }
        ]
    }
};

Tried to change the target with target: "node" but it introduce new problems. Downgrade to v1.2.1 solved the problem.

Please consider opt the default processor out of loading from the default config.

Request does not print method and url

Currently cy.request does not print any content of the request. It will be good to print the same details as cy.route

I tried to add this to Cypress.on('log:added', options => {

      if (options.name === 'request' && options.hookName && options.hookName === 'test') {
        options.message = options.renderProps.message;
      }

To get more information like status, response I need to wait for the promise in options to resolve. But I don't know how to do that.

If I console.log(options) the data is in consoleProps But console.log(options.consoleProps) does show the data. I guess the promise is not resolved. How do I fix this?

Cypress detected that you returned a promise from a command while also invoking one or more cy commands in that promise

Hi, I randomly get this error while running my tests in CI.

I cannot reproduce it in local and I don't understand what is happening.

Capture d’écran 2020-06-11 à 17 19 12

https://github.com/archfz/cypress-terminal-report/blob/master/src/installLogsCollector.js#L74


  > Cypress detected that you returned a promise from a command while also invoking one or more cy commands in that promise.

The command that returned the promise was:

  > `cy.wrap()`

The cy command you invoked inside the promise was:

  > `cy.task()`

Because Cypress commands are already promise-like, you don't need to wrap them or return your own promise.

Cypress will resolve your command with whatever the final Cypress command yields.

The reason this is an error instead of a warning is because Cypress internally queues commands serially whereas Promises execute as soon as they are invoked. Attempting to reconcile this would prevent Cypress from ever resolving.

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Because this error occurred during a `after each` hook we are skipping all of the remaining tests.```

Can't change collectTypes

Using version "2.0.0"

From the docs I'd expect that the following config code is correct,

  require('cypress-terminal-report/src/installLogsPrinter')(on, {
    collectTypes: ['cons:log', 'cons:info', 'cons:warn', 'cons:error'],
  })

But when I use that config I get this error.

 Error: [cypress-terminal-report] Invalid plugin install options:
=> .collectTypes: Additional properties not allowed

Log of assertion doesn't contain full expected value

Hi.

I have a cypress assertion: cy.title().should('equal', 'Hello - World') (This is just an example with the same format as the assertion that I am trying to do). If this assertion fails (e.g. the text should be Hello - World!, the log that I am getting is: assert expected **Hello** to equal **Hello - World!**

Is this a bug, or is there some config I haven't enabled?

After hook crashes if log files exist

The following code in BaseOutputProcessor.js:

hasSpecChunkWritten(spec) {
    return !!this.specChunksWritten[spec];
}

will throw if a log file for the current spec already exists in the output folder. This is because the following doesn't get invoked:

if (!fs.existsSync(this.file)) {
  this.prepareForWrite();
}

Due to this, this.specChunksWritten is never initialized before hasSpecChunkWritten tries to access it.

I see no extra output during `cypress run` when using plugin

I followed the instructions in the README.md and don't see any extra output during cypress run in my local terminal (which I'm assuming is where the output is supposed to be although this wasn't specified).

package.json

{
  "name": "cypress-test",
  "scripts": {
    "cypress:run": "cypress run --project cypress"
  },
  "dependencies": {},
  "devDependencies": {
    "cypress": "4.0.0",
    "cypress-terminal-report": "^0.2.2"
  }
}

plugins/index.js

module.exports = (on) => {
  require('cypress-terminal-report').installPlugin(on);
};

support/index.js

require('cypress-terminal-report').installSupport();

cypress.json - no special config that would overwrite these files

{}

spec.js My spec has a bunch of commands!

it('.type() - type into a DOM element', () => {
  cy.visit('http://example.cypress.io/commands/actions')
  cy.get('.action-email')
    .type('[email protected]').should('have.value', '[email protected]')
    .type('{leftarrow}{rightarrow}{uparrow}{downarrow}')
    .type('{del}{selectall}{backspace}')
    .type('{alt}{option}') //these are equivalent
    .type('{ctrl}{control}') //these are equivalent
    .type('{meta}{command}{cmd}') //these are equivalent
    .type('{shift}')
    .type('[email protected]', { delay: 100 })
    .should('have.value', '[email protected]')

  cy.get('.action-disabled')
    .type('disabled error checking', { force: true })
    .should('have.value', 'disabled error checking')
})

Output of cypress run

Screen Shot 2020-02-12 at 11 39 07 AM

Support also console.log

I am using webassembly and all stdout goes to console.log. I wonder if that could be redirected too

Can't change filterLog (Additional properties not allowed)

UPD: answer #50 (comment)

cypress-terminal-report: v^2.1.0

module.exports = (on) => {
  require("cypress-terminal-report/src/installLogsPrinter")(on, {
    printLogsToConsole: "always",
    filterLog: ([type, message, severity]) => {
      if (["cons:log"].includes(type)) {
        return true
      }
    },
  })
}

The function exported by the plugins file threw an error.
We invoked the function exported by /Users/name/projects/integration-testing/cypress/plugins/index.js, but it threw an error.

Error: [cypress-terminal-report] Invalid plugin install options:
=> .filterLog: Additional properties not allowed

at installLogsPrinter (/Users/name/projects/integration-testing/node_modules/cypress-terminal-report/src/installLogsPrinter.js:63:11)
at module.exports (/Users/name/projects/integration-testing/cypress/plugins/index.js:4:60)
at /Users/name/Library/Caches/Cypress/5.2.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:76:12
at tryCatcher (/Users/name/Library/Caches/Cypress/5.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
at Function.Promise.attempt.Promise.try (/Users/name/Library/Caches/Cypress/5.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/metho

commands from 'before' hook are missing in the report

I've noticed that commands from before and after hooks don't show up in the report(beforeEach and afterEach works fine). Not quite sure, but it looks like this logs overwritten at some point.

Also, couldn't find any test for hooks so not sure if it's some kind of regression.

I'm using cypress 4.12.0 if it's matters.

A test case could be just something like:

describe('Always red test', function () {
  before(function () {
    cy.log('from before');
  });
  beforeEach(function () {
    cy.log('from beforeEach');
  });
  after(function () {
    cy.log('from after');
  });
  afterEach(function () {
    cy.log('from afterEach');
  });
  it('passed it', function () {
    cy.log('from it');
  });
});

The task 'ctrAfter' was not handled in the plugins file.

hey! :)

seems like the new version 1.3.0 introduced a breaking change, when using installSupport without any options:

CypressError: `cy.task('ctrAfter')` failed with the following error:

The task 'ctrAfter' was not handled in the plugins file. The following tasks are registered: ctrLogMessages, log

Fix this in your plugins file here:
/src/cypress/plugins/index.js

Uncaught TypeError: Cannot set property '2' of undefined

I am getting this error when running all tests.
This does not occure in single runs.

I figured out that checking for undefined in here fixes the issue as well as resetting

logsChainId = {};

in the .on('test') callback here.

Looking forward to hear any feedback or see any fixes.

Best,
Sven

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.