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

[BUG] moment-loader fails to find default export #2500

Closed
awilkins opened this issue Jun 7, 2018 · 5 comments
Closed

[BUG] moment-loader fails to find default export #2500

awilkins opened this issue Jun 7, 2018 · 5 comments
Assignees
Labels
STATE: Auto-locked An issue has been automatically locked by the Lock bot. SYSTEM: reporting TYPE: bug The described behavior is considered as wrong (bug).

Comments

@awilkins
Copy link

awilkins commented Jun 7, 2018

What is the current behavior?

Attempting to

import { Selector } from 'testcafe';

Get the stack trace below. I would suspect it's something to do with ...

What is the expected behavior?

Code works

Note that line error reported on is nothing to do with bug - project has a .babelrc, and these tests are being run from inside Jest, rather than from Testcafe - but they import modules that import Testcafe types. Line reported is somewhere in transpiled output.

TypeError: Cannot read property 'exports' of undefined

      2 | /* eslint-disable class-methods-use-this */
      3 | import typeof { t } from 'testcafe';
    > 4 | import type { Address } from './address';
      5 | 
      6 | const { Selector } = require('testcafe');
      7 | 
      
      at getMomentModuleWithDurationFormatPatch (node_modules/testcafe/lib/utils/moment-loader.js:85:37)
      at Object.<anonymous> (node_modules/testcafe/lib/utils/moment-loader.js:88:19)
      at Object.<anonymous> (node_modules/testcafe/lib/reporter/plugin-host.js:23:21)
      at Object.<anonymous> (node_modules/testcafe/lib/reporter/index.js:11:19)
      at Object.<anonymous> (node_modules/testcafe/lib/runner/index.js:47:17)
      at Object.<anonymous> (node_modules/testcafe/lib/testcafe.js:39:15)
      at Object.<anonymous> (node_modules/testcafe/lib/index.js:166:17)
      at Object.<anonymous> (test/acceptance/models/page-model.js:4:22)
      at Object.<anonymous> (test/acceptance/models/app-model.js:3:18)
      at Object.<anonymous> (test/unit/review.test.js:7:17)

Workaround

Use testcafe version 0.20.2 which doesn't have moment-loader.js

Specify your

  • operating system: Ubuntu 16.04
  • testcafe version: 0.20.3
  • node.js version: 8.11.2
  • jest : 22.4.4

.babelrc file

{
  "plugins": ["transform-class-properties"],
  "presets": [
    [
      "env", {
        "targets": {
          "node": "current"
        }
      }
    ],
    "flow"
  ]
}
@AndreyBelym AndreyBelym added the STATE: Need clarification An issue lacks information for further research. label Jun 7, 2018
@AndreyBelym
Copy link
Contributor

Hi @awilkins, likely it's related to require.cache invalidation, or installed modules structure. Could you share a minimal example project similar to your setup? Do you use packages that can modify package's cache?

@awilkins
Copy link
Author

Here's a repo that demonstrates the bug :

https://github.com/awilkins/testcafe-bug-2500

Running this produces a similar stack trace to above.

yarn install
yarn jest

@miherlosev
Copy link
Collaborator

Hi @awilkins

Thank you for the example to reproduce. I've reproduced the bug.

@miherlosev miherlosev added TYPE: bug The described behavior is considered as wrong (bug). SYSTEM: reporting SYSTEM: plugins and removed STATE: Need clarification An issue lacks information for further research. SYSTEM: plugins labels Jun 13, 2018
@AndreyBelym AndreyBelym added this to the Sprint #17 milestone Aug 30, 2018
@AndreyBelym
Copy link
Contributor

Working on it. Looks like that jest prevents module caching: jestjs/jest#4940, we can work around it.

AndreyBelym added a commit to AndreyBelym/testcafe that referenced this issue Sep 4, 2018
@AndreyBelym AndreyBelym assigned AndreyBelym and unassigned AlexKamaev Sep 4, 2018
@AndreyBelym AndreyBelym modified the milestones: Sprint #17, Sprint #18 Sep 17, 2018
AndreyBelym added a commit to AndreyBelym/testcafe that referenced this issue Sep 18, 2018
@lock
Copy link

lock bot commented Mar 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests. For TestCafe API, usage and configuration inquiries, we recommend asking them on StackOverflow.

@lock lock bot added the STATE: Auto-locked An issue has been automatically locked by the Lock bot. label Mar 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 28, 2019
kirovboris pushed a commit to kirovboris/testcafe-phoenix that referenced this issue Dec 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
STATE: Auto-locked An issue has been automatically locked by the Lock bot. SYSTEM: reporting TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

4 participants