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

Importing two files in shared.js from the same step_definitions folder will fail file2 #40

Closed
stevepkuo opened this issue Apr 10, 2018 · 2 comments

Comments

@stevepkuo
Copy link

I upgraded to version 0.4.0, and put "cypress-cucumber-preprocessor": "^0.4.0" in package.json, and then did "npm install".
However I'm still seeing a similar issue as below:
#30

In my support/step_definitions folder there is implementations.js, helpers.js, and shared.js.

Inside shared.js
const implementations = require('./implementations');
const helpers = require('./helpers');

Importing implementations.js is fine. But it'll look for helpers.js relative to the integration folder, instead of /support/step_definitions.

@lgandecki
Copy link
Collaborator

Hello @stevepkuo , thanks for reporting!
But this is a bit weird... I just tried in the current version and it worked..
If you could try with the newest version (0.6.0 ) that would be great, maybe I messed up the versions.
But if the problem still persists - could you make a simple reproduction?

I've tried:

let dataToBeLoaded;
let differentDataToBeLoaded;
given("I require a file", () => {
  dataToBeLoaded = require("./requiringFilesData");
});

given("I require a different file", () => {
  differentDataToBeLoaded = require("./requiringDifferentFilesData");
});

then("I can access theirs data", () => {
  expect(dataToBeLoaded.IAmImported).to.equal(true);
  expect(differentDataToBeLoaded.IAmAlsoImported).to.equal(true);
});

and also

const dataToBeLoaded = require("./requiringFilesData");
const differentDataToBeLoaded = require("./requiringDifferentFilesData");

given("I require a file", () => {
});

given("I require a different file", () => {
});

then("I can access theirs data", () => {
  expect(dataToBeLoaded.IAmImported).to.equal(true);
  expect(differentDataToBeLoaded.IAmAlsoImported).to.equal(true);
});

Feature file:

Feature: Requiring Files

  Scenario: Require Two Files
    Given I require a file
    And I require a different file
    Then I can access theirs data

the files I require are trivial:

module.exports = {
  IAmAlsoImported: true
};

and the second one exports "IAmImported: true" in it

@stevepkuo
Copy link
Author

Sorry, it was a mistake on my part. I didn't realize that for my team's project, plugins/index.js was ignoring/overwriting cypress-cucumber-preprocessor's index.js which contains the exact fix I wanted. Once I accounted for that, and used version 0.6.0, the problem went away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants