Cypress: Attachment path injected into the test object is not passed to the reporter

Created on 16 Jan 2019  路  3Comments  路  Source: cypress-io/cypress

Current behavior:

New feature in mocha-junit-reporter allows for an attachment path to be included in the report output file. To achieve this the attachment path is injected into the test object:

it ('should include attachment', function () {
  this.test.attachments = ['/absolut/path/to/file.png'];
});

(as described here: https://github.com/michaelleeallen/mocha-junit-reporter#attachments)

Currently Cypress does not pass the injected _attachment_ in the test object passed to the reporter:

{
  "title": "should include attachment",
  "pending": false,
  "type": "test",
  "body": "function () {\n  this.test.attachments = ['/absolut/path/to/file.png'];\n}",
  "duration": 45,
  "state": "passed",
  "parent": "#<Suite>",
  "id": "r2",
  "wallClockStartedAt": "2019-01-16T14:36:45.039Z",
  "timings": {
    "lifecycle": 40,
    "test": {
      "fnDuration": 1,
      "afterFnDuration": 3
    }
  },
  "speed": "medium"
}

Desired behavior:

Cypress passes the injected _attachment_ in the test object passed to the reporter:

{
  "title": "should include attachment",
  "attachments": '/absolut/path/to/file.png',
  "pending": false,
  "type": "test",
  "body": "function () {\n  this.test.attachments = ['/absolut/path/to/file.png'];\n}",
  "duration": 45,
  "state": "passed",
  "parent": "#<Suite>",
  "id": "r2",
  "wallClockStartedAt": "2019-01-16T14:36:45.039Z",
  "timings": {
    "lifecycle": 40,
    "test": {
      "fnDuration": 1,
      "afterFnDuration": 3
    }
  },
  "speed": "medium"
}

Steps to reproduce: (app code and test code)

Run test:

it ('should include attachment', function () {
  this.test.attachments = ['/absolut/path/to/file.png'];
});

And view the object that is passed to the reporter.

Versions

cypress: 3.1.4
proposal 馃挕 reporters 馃搫 feature

Most helpful comment

@Bkucera @jennifer-shehane is there any way using attachments in the report file? (junit) was anything added since this issue was opened?

All 3 comments

@bkosse since we expect the test context to adhere to a strict schema, we explicitly construct the final context before passing it to reporters, picking only the values we expect off of the mocha context.

However, we are working on a feature to allow you to attach arbitrary data onto a ctx object that can be passed onto reporters, and should be in an issue soon

https://github.com/cypress-io/cypress/blob/4b368830faca8794859abd8972f0c67a5bdd5839/packages/server/lib/reporter.coffee#L66

@Bkucera @jennifer-shehane is there any way using attachments in the report file? (junit) was anything added since this issue was opened?

This issue is still in the 'proposal' stage, which means no work has been done on this issue as of today, so we do not have an estimate on when this will be delivered.

Was this page helpful?
0 / 5 - 0 ratings