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

require() not working after upgrade #6403

Closed
nisuxyz opened this issue Feb 10, 2020 · 3 comments · Fixed by #6419
Closed

require() not working after upgrade #6403

nisuxyz opened this issue Feb 10, 2020 · 3 comments · Fixed by #6419
Labels
type: regression A bug that didn't appear until a specific Cy version release v4.0.0 🐛 Issue present since 4.0.0

Comments

@nisuxyz
Copy link

nisuxyz commented Feb 10, 2020

Current behavior:

On 3.8.3, I have tests that require() either other specs directly or functions that return a spec, and it works great. After updating to 4.0, all my specs with require() calls break with the following error:

2020-02-10-113001_5360x1440_scrot

Reverting to 3.8.3 restores desired behavior.

Desired behavior:

Specs can require() other specs or functions

Test code to reproduce

Create a file that exports a function that returns a describe():

export default (config) => {
  return describe(config.title, () => {
    // does stuff here
  }
}

require() the function in another spec:

describe('a different spec', () => {
  require('path/to/first/spec.spec.js')({ config: 'object', that: 'is', passed: 'in' });
});

Versions

Cypress 4.0.1, chrome and firefox, Manjaro Linux 18.1.5 (5.5.0-1 kernel)

@jennifer-shehane jennifer-shehane added v4.0.0 🐛 Issue present since 4.0.0 type: regression A bug that didn't appear until a specific Cy version release labels Feb 11, 2020
@cypress-bot cypress-bot bot added the stage: needs investigating Someone from Cypress needs to look at this label Feb 11, 2020
@jennifer-shehane
Copy link
Member

jennifer-shehane commented Feb 11, 2020

This is a regression in 4.0.0. This is likely due to the @cypress/browserify-preprocessor dependency update from 1.1.2 to 2.1.1

My working example:

spec.js

describe('a different spec', () => {
  const num = require('./spec2.js')(4)

  it('foo', () => {
    expect(num).to.eq(64)
  })
})

spec2.js

export default function cube(x) {
  return x * x * x
}

3.8.3

Screen Shot 2020-02-11 at 2 39 40 PM

4.0.0

Screen Shot 2020-02-11 at 2 41 55 PM

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Feb 12, 2020

The code for this is done in cypress-io/cypress#6419, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label Feb 12, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Feb 14, 2020

Released in 4.0.2.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v4.0.2, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Feb 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: regression A bug that didn't appear until a specific Cy version release v4.0.0 🐛 Issue present since 4.0.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants