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

Fix (and add) yarn rw test web in run-e2e script #2068

Closed
thedavidprice opened this issue Mar 23, 2021 · 2 comments · Fixed by #2329
Closed

Fix (and add) yarn rw test web in run-e2e script #2068

thedavidprice opened this issue Mar 23, 2021 · 2 comments · Fixed by #2329
Assignees

Comments

@thedavidprice
Copy link
Contributor

related to #1886

@peterp @dac09

We are currently not able to run yarn rw test web in our CI check due to undiagnosed issues from the package linking process. I'm still tracking and including a manual QA check for yarn rw test web, however, it feels like it's bound to get missed sooner or later. What should the next steps be here:

  • diagnose and try to resolve via a change to package linking?
  • implement a different process for including yarn rw test in our CI process?
  • ... ?

Example Jest failure message:

 FAIL   web  web/src/components/BlogPostsCell/BlogPostsCell.test.js
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/en/ecmascript-modules for how to enable it.
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /private/var/folders/gj/_y54h7q11mz9rwnhn16h6yrr0000gn/T/redwood-e2e/2021-03-23T15-48-36.323Z/packages/structure/dist/model/RWCell.js:3
    import { withCell } from "@redwoodjs/web";
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      33 | var _URL = require("../x/URL");
      34 |
    > 35 | var _RWCell = require("./RWCell");
         |               ^
      36 |
      37 | var _RWComponent = require("./RWComponent");
      38 |

      at Runtime.createScriptFromCode (../node_modules/jest-runtime/build/index.js:1350:14)
      at Object.<anonymous> (../packages/structure/dist/model/RWProject.js:35:15)

How to Replicate

The error above came from an E2E run. However, I believe you can reproduce this on any project where you are using yarn rwt link ...

@peterp
Copy link
Contributor

peterp commented Mar 23, 2021

I was trying to debug this issue: #2039

What I found was that if you ran yarn rw test in e2e with the redwood/packages in the repository it didn't work, but if you ran yarn jest it did work.

I'm assuming there's a problem with paths, that jest doesn't know where it's starting from... Or "jest" is picking up tests or trying to do coverage in the redwood/packages folder.

@thedavidprice
Copy link
Contributor Author

bumping this on — likely too late for v0.29 but high priority when possible to dig in. I'm weak on the fundamentals here but game to dig in given direction.

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

Successfully merging a pull request may close this issue.

2 participants