Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2.0.12 Is not generating errors on the console. #63

Open
sibyldawn opened this issue Jun 20, 2019 · 5 comments
Open

Version 2.0.12 Is not generating errors on the console. #63

sibyldawn opened this issue Jun 20, 2019 · 5 comments
Labels
bug Something isn't working

Comments

@sibyldawn
Copy link

@bencompton First of all, kudos on adding a reporting in json! I noticed when I run my test and it has errors, I only see that it failed but I don't see any error messages on my console, so it's hard to debug my test. The way I go around is by adding try-catches to log the errors, but it also passes the test even though it failed the assertion. I'm not sure if this is a known error but would love to know if there's a configuration I could do to force the reporter to log errors.

@sibyldawn
Copy link
Author

@bencompton

@james-goddard12
Copy link

I think this is the same issues I'm seeing. When expect fails, the exception is swallowed and the console just points the failure at test() without any useful output (eg. expected x but received y). only workaround is as mentioned above, to wrap the expect in try/catch

@nguillemin
Copy link

nguillemin commented Aug 28, 2019

There might be a regression or a change of behavior, 2.0.11 would point to which part of the test failed (ie. given), but 2.0.12 point to the overall test.

For my same code and error, 2.0.11 would return
` ReferenceError: getByText is not defined

  50 | 
  51 | 
> 52 |         given('my given step', () => {
     |                                                     ^
  53 |             ({getByText} = render(<MyComponent />))
  54 |         });
  55 | `

while 2.0.12 now returns
48 | > 49 | test.only('My test', ({ given, when, then, and }) => { | ^ 50 | 51 | 52 | given('my given step', () => {
without indication of what the error actually is

@bencompton bencompton added the bug Something isn't working label Sep 26, 2019
@bencompton
Copy link
Owner

#27 is still in preview, and 2.0.11 is still the latest stable version. Sounds like there is a regression in 2.0.12 with with error reporting. My apologies to everyone for not being very responsive with this project lately. I hope to carve out some time to finish up #27 soon.

@christian-eriksson
Copy link
Contributor

@nguillemin and @sibyldawn I'm trying to reproduce this by creating a simple test that fails:

specs/features/test.feature

Feature: Test feature

  Scenario: My test
    Given my given step

specs/step-definitions/test.steps.js

import { loadFeature, defineFeature } from 'jest-cucumber';

const feature = loadFeature('./specs/features/test.feature');

defineFeature(feature, (test) => {
    test('My test', ({ given }) => {
        given('my given step', () => {
            expect(true).toBe(false);
         });
    });
});

package.json

{
  "name": "test",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "jest"
  },
  "devDependencies": {
    "@babel/core": "^7.8.6",
    "@babel/preset-env": "^7.8.6",
    "babel-jest": "^25.1.0",
    "jest-cucumber": "2.0.12"
  },
  "jest": {
    "clearMocks": true,
    "testEnvironment": "node",
    "testMatch": [
      "**/*.steps.js"
    ]
  }
}

babel.config.js

module.exports = {
  presets: [
    [
      '@babel/preset-env',
      {
        targets: {
          node: 'current',
        },
      },
    ],
  ],
};

but it fails with, I believe, the expected information:

  FAIL  specs/step-definitions/test.steps.js
  Test feature
    ✕ My test (10ms)

  ● Test feature › My test

    Failed: Object {
      "matcherResult": Object {
        "actual": true,
        "expected": false,
        "message": [Function anonymous],
        "name": "toBe",
        "pass": false,
      },
      "message": "An error occurred while executing step \"my given step\": expect(received).toBe(expected) // Object.is equality

    Expected: false
    Received: true",
    }

      4 | 
      5 | defineFeature(feature, (test) => {
    > 6 |     test('My test', ({ given }) => {
        |     ^
      7 |         given('my given step', () => {
      8 |             // let test;
      9 |             // console.log(test.undefined);

      at Env.it (node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:91:24)
      at defineScenario (node_modules/jest-cucumber/src/feature-definition-creation.ts:119:5)
      at test (node_modules/jest-cucumber/src/feature-definition-creation.ts:227:13)
      at Object.<anonymous>.test (specs/step-definitions/test.steps.js:6:5)
      at Suite.<anonymous> (node_modules/jest-cucumber/src/feature-definition-creation.ts:314:9)
      at defineFeature (node_modules/jest-cucumber/src/feature-definition-creation.ts:313:5)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        0.577s, estimated 1s
Ran all test suites.

I'm using version 2.0.12 from npm. Is your setup different?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants