Comments (21)
It seems this is not quite resolved.
I am getting the following error:
Jest: synchronous transformer node_modules/svelte-jester/src/transformer.js must export a "process" function.
"svelte-jester": "2.0.1"
"jest": "27.0.6"
"svelte": "3.41.0"
jest config
transform: {
"^.+\\.ts$": "ts-jest",
"^.+\\.svelte$": [
"svelte-jester",
{
"preprocess": true
}
],
},
from svelte-jester.
Support now exists in Jest! However, it hasn't yet been released yet, so we'll need to wait a little in order to be able to use it
from svelte-jester.
@ritchieanesco #74 was fixed by #75 but that fix hasn't made its way into a released version yet. I don't know why, because 2.1.2 is unusable, so I'd have thought that 2.1.3 would be more urgent. But once 2.1.3 comes out, it will work. I've verified the fix in #75 by cloning the svelte-jester repo and putting "svelte-jester": "../svelte-jester"
in my package.json, and then I could successfully use jest.unstable_mockModule
in my Svelte unit tests.
So wait for 2.1.3 to come out and it should work for you.
from svelte-jester.
Jest 27 has just been released. Once my PR #46 has been merged, I will give it a try.
from svelte-jester.
Extending on a few things @benmccann noted here that I agree with.
If we want to support async transforms and not tie ourselves to Jest versioning, we'll need to support both sync and async transformers for the time being until a reasonable time where we can deprecate sync transformers. We can't force existing codebases using
26.x
to upgrade, and if they decide not to upgrade they'll miss bug fixes or any new features. Thus, we need to support both for now.I'm not sure what the best way will be to determine if async transforms are supported. Ideas include:
* Node environment variable that indicates current Jest version? * Extracting Jest version from `pacakge.json`? * Some kind of check for async transformer support?
Keep in mind, it may executed inside a monorepo, and note any existing
svelte-jester
options that may change final transformation.
From my understanding, we can keep the existing code and just write a new async transformer. I think I already did some steps to extract functionality into seperate files. The only difference will be, how the transformer is called. Either as a subprocess with node or as an async function.
from svelte-jester.
Awesome thanks for setting this up @benmccann!
from svelte-jester.
I was just curious @sebastianrothe if this is something you're still planning to give a go of?
from svelte-jester.
I was just curious @sebastianrothe if this is something you're still planning to give a go of?
I'd love to, but my project at work takes up all my time. I'll try to give it a go at the beginning of next month.
from svelte-jester.
Looks like this will probably depend on #55. There's a PR for it though: #56
from svelte-jester.
Extending on a few things @benmccann noted here that I agree with.
If we want to support async transforms and not tie ourselves to Jest versioning, we'll need to support both sync and async transformers for the time being until a reasonable time where we can deprecate sync transformers. We can't force existing codebases using 26.x
to upgrade, and if they decide not to upgrade they'll miss bug fixes or any new features. Thus, we need to support both for now.
I'm not sure what the best way will be to determine if async transforms are supported. Ideas include:
- Node environment variable that indicates current Jest version?
- Extracting Jest version from
pacakge.json
? - Some kind of check for async transformer support?
Keep in mind, it may executed inside a monorepo, and note any existing svelte-jester
options that may change final transformation.
from svelte-jester.
We can't force existing codebases using 26.x to upgrade
I'm not sure it'd be much of an imposition to ask people to upgrade to v27.x. I just took a look at the breaking changes in v27 and they seem quite minor: https://jestjs.io/blog/2021/05/25/jest-27#features-coming-with-breaking-changes
from svelte-jester.
I'll be honest I didn't actually look at the breaking changes. There seems to be nothing serious, I was thinking of a few other things outside of the noted breaking changes, but again nothing of importance.
If it all seems okay, we can just ignore what I said and next major version of svelte-jester
can simply transition to async only transformers and bump minimum version for Jest in peer deps to >=27
.
from svelte-jester.
I don't understand why we'd want to keep the existing code. Calling as a subprocess with node is purely worse. We should just always return an async transformer
from svelte-jester.
Well, Jest <27 doesn't understand async transformers. If we rewrite the code, we loose compatibility with Jest 26.x
It is fine to me, but I just wanted to point that out.
Guess, people who need to run Jest 26.x can always use an older version, right.
from svelte-jester.
Yeah, that's fine. We listed jest >= 27
as a peer dependency:
from svelte-jester.
Yes, I am seeing same error as @gorjan-mishevski. Same jest config file
[email protected]
[email protected]
[email protected]
from svelte-jester.
+1. Also same config.
[email protected]
[email protected]
[email protected]
from svelte-jester.
Please use the latest version: 2.1.2
from svelte-jester.
@benmccann updating to 2.1.2 now gives me
TypeError: Jest: a transform must export a `process` or `processAsync` function.
which was raised in this issue #74. Has this issue regressed?
from svelte-jester.
I had the same problem as @gorjan-mishevski but 2.1.3 is out now for svelte-jester
. I updated jest
as well to the currently latest version (27.2.0) and now I get a new error:
Cannot find module './preprocess.js'
Require stack:
node_modules/svelte-jester/dist/transformer.cjs
node_modules/@jest/transform/node_modules/jest-util/build/requireOrImportModule.js
node_modules/@jest/transform/node_modules/jest-util/build/index.js
node_modules/@jest/transform/build/ScriptTransformer.js
node_modules/@jest/transform/build/index.js
node_modules/jest-runtime/build/index.js
node_modules/@jest/core/build/cli/index.js
node_modules/@jest/core/build/jest.js
node_modules/jest/node_modules/jest-cli/build/cli/index.js
node_modules/jest/node_modules/jest-cli/bin/jest.js
node_modules/jest/bin/jest.js
at Object.processSync [as process] (node_modules/svelte-jester/dist/transformer.cjs:115:32)
at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:612:31)
at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:758:40)
at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:815:19)
from svelte-jester.
I had the same problem as @gorjan-mishevski but 2.1.3 is out now for
svelte-jester
. I updatedjest
as well to the currently latest version (27.2.0) and now I get a new error:Cannot find module './preprocess.js' Require stack: node_modules/svelte-jester/dist/transformer.cjs node_modules/@jest/transform/node_modules/jest-util/build/requireOrImportModule.js node_modules/@jest/transform/node_modules/jest-util/build/index.js node_modules/@jest/transform/build/ScriptTransformer.js node_modules/@jest/transform/build/index.js node_modules/jest-runtime/build/index.js node_modules/@jest/core/build/cli/index.js node_modules/@jest/core/build/jest.js node_modules/jest/node_modules/jest-cli/build/cli/index.js node_modules/jest/node_modules/jest-cli/bin/jest.js node_modules/jest/bin/jest.js at Object.processSync [as process] (node_modules/svelte-jester/dist/transformer.cjs:115:32) at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:612:31) at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:758:40) at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:815:19)
@n00pper it was left out of the published version but is being addressed 👍
#81
from svelte-jester.
Related Issues (20)
- Add presets like vue-jest
- Svelte 4 support HOT 7
- Add mechanism to call beforeEach() and afterEach() manually inside an it block HOT 1
- Allow to use CJS with Svelte 4 without throwing an error HOT 3
- Call `compileModule` for `.svelte.js` files in Svelte 5 HOT 8
- Phantom file listed in coverage HOT 2
- Transformer.js must export a "process" function - jester v2.0.1 jest 27 HOT 33
- Support components mocks HOT 2
- yarn vs npm
- jestOptions?.transformerConfig Unexpected token '.' HOT 2
- TypeError [ERR_INVALID_ARG_TYPE] HOT 16
- Regression in 2.1.2: a transform must export a `process` or `processAsync` function. HOT 9
- Cannot find module './preprocess.js' HOT 13
- TypeError [ERR_INVALID_ARG_TYPE] - Sapper HOT 2
- Cannot import from context="module" HOT 10
- Image imports that use typescript alias returns undefined HOT 1
- ParseError: Colon is expected (svelte with scss style) HOT 1
- Coverage of untested files not collected HOT 8
- Completely fails when using preprocessing HOT 4
- <svelte:component/> breaks rendering with `TypeError: switch_value is not a constructor` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svelte-jester.