Cypress 3.3.1 does not load plugins/index.js on Linux
See original GitHub issueCurrent behavior:
I tried adding the cypress-cucumber-preprocessor plugin so I can use feature files. Cypress loads the preprocessor on Windows but not if I run the same config on Linux.
I have a cypress/plugins/index.js
file that is not loaded. On Windows 10, my .feature
file is run successfully. On Linux (Ubuntu 19.04) I see:
Module parse failed: Unexpected token (1:12)
You may need an appropriate loader to handle this file type.
> Feature: It runs
|
| I want to see the startup page
Oops...we found an error preparing this test file:
cypress/integration/smoke.feature
The error was:
./cypress/integration/smoke.feature 1:12
Module parse failed: Unexpected token (1:12)
You may need an appropriate loader to handle this file type.
> Feature: It runs
|
| I want to see the startup page
This occurred while Cypress was compiling and bundling your test code. This is usually caused by:
- A missing file or dependency
- A syntax error in the file or one of its dependencies
Fix the error in your code and re-run your tests.
If I run with DEBUG=cypress:*
then on Windows I see a log statement I put in my cypress/plugins/index.js
in the log:
const cucumber = require('cypress-cucumber-preprocessor').default
module.exports = (on, config) => {
console.log('CUCUMBER', config);
on('file:preprocessor', cucumber());
}
Note the lines following CUCUMBER { animationDistanceThreshold: 5,
below.
2019-06-25T09:38:26.607Z cypress:server:plugins:child require pluginsFile
2019-06-25T09:38:28.534Z cypress:server:plugins:child run plugins function
2019-06-25T09:38:28.534Z cypress:server:plugins:child register event _get:task:body with id 0
2019-06-25T09:38:28.534Z cypress:server:plugins:child register event _get:task:keys with id 1
CUCUMBER { animationDistanceThreshold: 5,
fileServerFolder: 'C:\\Users\\user\\project',
baseUrl: null,
fixturesFolder: 'C:\\Users\\user\\project\\cypress\\fixtures',
chromeWebSecurity: false,
modifyObstructiveCode: false,
integrationFolder: 'C:\\Users\\user\\project\\cypress\\integration',
env:
{ http_proxy: '<my proxy>',
https_proxy: '<my proxy>',
no_proxy: 'localhost' },
pluginsFile: 'C:\\Users\\user\\project\\cypress\\plugins\\index.js',
hosts: null,
screenshotsFolder: 'C:\\Users\\user\\project\\cypress\\screenshots',
numTestsKeptInMemory: 0,
supportFile: 'C:\\Users\\user\\project\\cypress\\support\\index.js',
port: null,
supportFolder: 'C:\\Users\\user\\project\\cypress\\support',
reporter: 'spec',
videosFolder: 'C:\\Users\\user\\project\\cypress\\videos',
reporterOptions: null,
testFiles: '**/*.*',
defaultCommandTimeout: 4000,
trashAssetsBeforeRuns: true,
execTimeout: 60000,
blacklistHosts: null,
pageLoadTimeout: 60000,
userAgent: null,
requestTimeout: 5000,
viewportWidth: 1000,
responseTimeout: 30000,
viewportHeight: 800,
taskTimeout: 60000,
video: true,
videoCompression: 32,
videoUploadOnPasses: true,
watchForFileChanges: false,
waitForAnimations: true }
2019-06-25T09:38:28.546Z cypress:server:plugins:child register event file:preprocessor with id 2
2019-06-25T09:38:28.552Z cypress:server:plugins register plugins process event _get:task:body with id 0
2019-06-25T09:38:28.552Z cypress:server:plugins register event '_get:task:body'
2019-06-25T09:38:28.552Z cypress:server:plugins register plugins process event _get:task:keys with id 1
2019-06-25T09:38:28.552Z cypress:server:plugins register event '_get:task:keys'
The log from Linux does not show the console.log
being run:
2019-06-24T16:34:28.959Z cypress:server:plugins:child require pluginsFile
2019-06-24T16:34:29.609Z cypress:webpack user options: { webpackOptions: { resolve: { extensions: [Array] }, module: { rules: [Array] } } }
2019-06-24T16:34:29.613Z cypress:server:plugins:child run plugins function
2019-06-24T16:34:29.613Z cypress:server:plugins:child register event _get:task:body with id 0
2019-06-24T16:34:29.614Z cypress:server:plugins:child register event _get:task:keys with id 1
2019-06-24T16:34:29.614Z cypress:server:plugins:child register event file:preprocessor with id 2
2019-06-24T16:34:29.618Z cypress:server:plugins register plugins process event _get:task:body with id 0
2019-06-24T16:34:29.618Z cypress:server:plugins register event '_get:task:body'
2019-06-24T16:34:29.619Z cypress:server:plugins register plugins process event _get:task:keys with id 1
2019-06-24T16:34:29.619Z cypress:server:plugins register event '_get:task:keys'
Desired behavior:
It should preprocess .feature
files on Windows and Linux.
Steps to reproduce: (app code and test code)
Add "cypress-cucumber-preprocessor": "^1.12.0"
to your package.json
file and run npm install
Add the following to cypress/plugins/index.js
:
const cucumber = require('cypress-cucumber-preprocessor').default
module.exports = (on, config) => {
console.log('CUCUMBER', config);
on('file:preprocessor', cucumber());
}
Create a file cypress/integration/test.feature
file with these contents:
Note the console.log
.
Feature: It runs
I want to see the startup page
@smoke
Scenario: Open the app
Given I open the app
Then I see something
Create a file cypress/integration/test/test.js
with these contents:
import { Given } from "cypress-cucumber-preprocessor/steps";
import { Then } from 'cypress-cucumber-preprocessor/steps';
const url = 'http://localhost:4200';
Given('I open the app', () => {
cy.visit(url)
})
Then(`I see something`, () => {
cy.title().should('exist')
})
Versions
Cypress 3.3.1 and 3.1.0 cypress-cucumber-preprocessor 1.12.0 Windows 10 and Ubuntu 19.04 Electron (whatever version is installed by cypress)
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
@edoloughlin : Stupid question but, is your
pluginsFile
set to false?Right now there doesn’t seem to be enough information to reproduce the problem on our end. We’ll have to close this issue until we can reproduce it. This does not mean that your issue is not happening - it just means that we do not have a path to move forward.
Please comment in this issue with a reproducible example and we will consider reopening the issue. Here are some tips for providing a Short, Self Contained, Correct, Example and our own Troubleshooting Cypress guide.