-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
chore: update jest
-related dependencies to v28
#3400
Conversation
Hi @penx, Welcome, and thank you for contributing to Remix! Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once. You may review the CLA and sign it by adding your name to contributors.yml. Once the CLA is signed, the If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at [email protected]. Thanks! - The Remix team |
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳 |
jest
-related dependencies to v28
Moving to draft while I review the babel config changes https://jestjs.io/docs/upgrading-to-jest28#babel-config |
Example failing testFAIL react packages/remix-react/__tests__/transition-test.tsx
● Test suite failed to run
Jest encountered an unexpected token
Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.
Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.
By default "node_modules" folder is ignored by transformers.
Here's what you can do:
• If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
• If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
• 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/configuration
For information about custom transformations, see:
https://jestjs.io/docs/code-transformation
Details:
/home/runner/work/remix/remix/node_modules/@remix-run/web-fetch/src/lib.js:4
export { ReadableStream, Blob, FormData } from './package.js';
^^^^^^
SyntaxError: Unexpected token 'export'
30 | NodeRequestInit as RequestInit,
31 | NodeResponseInit as ResponseInit,
> 32 | };
| ^
33 |
34 | class NodeRequest extends WebRequest {
35 | constructor(info: NodeRequestInfo, init?: NodeRequestInit) {
at Runtime.createScriptFromCode (../../node_modules/jest-runtime/build/index.js:1773:14)
at Object.<anonymous> (../remix-node/fetch.ts:32:17)
I think the failing tests are due to the following from "exports": {
".": {
"browser": "./src/lib.js",
"require": "./dist/lib.node.cjs",
"import": "./src/lib.node.js",
"types": "./dist/src/lib.node.d.ts"
}, This means that Jest 28 tries to import We can likely tell Jest to transpile this module but it should probably be fixed upstream. @chaance ? |
Further to this, I can add the following to the jest config: transformIgnorePatterns: [
"/node_modules/(?!(@remix-run/web-fetch|@remix-run/web-blob|@remix-run/web-stream|@remix-run/web-form-data|@remix-run/web-file)/)",
], But get a new, but similar error: FAIL react packages/remix-react/__tests__/transition-test.tsx
● Test suite failed to run
TypeError: Class extends value undefined is not a constructor or null
34 | class NodeRequest extends WebRequest {
35 | constructor(info: NodeRequestInfo, init?: NodeRequestInit) {
> 36 | super(info, init as RequestInit);
| ^
37 | }
38 |
39 | public get headers(): WebHeaders { This seems to relate to the types output by export { default, fetch, Headers, Request, Response } from "./fetch.js";
export { ReadableStream, Blob, FormData } from "./package.js";
//# sourceMappingURL=lib.node.d.ts.map
fetch.js and package.js do not exist in the distributed edit: opened as #3402 |
@penx Now that GoogleCloudPlatform/functions-framework-nodejs#461 is merged, do we still need |
yes, as per #3402 (comment) Here's the test output on my |
@MichaelDeBoey sure I’ll try find some time this Wednesday to clean up this and my unrelated examples PR |
@MichaelDeBoey I've rebased, but am pretty sure this is still blocked by #3402. I had opened remix-run/web-std-io#11 which was approved almost a year ago but not merged. |
|
@MichaelDeBoey thanks for the ping! I'm mostly interested in getting jest/jsdom upgraded on the react-router side, but good to see if happening here too ❤️ |
Closing in favor of #7220 |
Closes: Discussion at #3397 (comment)
Testing Strategy: