Giter VIP home page Giter VIP logo

Comments (21)

gorjan-mishevski avatar gorjan-mishevski commented on August 18, 2024 15

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.

benmccann avatar benmccann commented on August 18, 2024 7

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.

rmunn avatar rmunn commented on August 18, 2024 3

@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.

sebastianrothe avatar sebastianrothe commented on August 18, 2024 1

Jest 27 has just been released. Once my PR #46 has been merged, I will give it a try.

from svelte-jester.

sebastianrothe avatar sebastianrothe commented on August 18, 2024 1

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.

mihar-22 avatar mihar-22 commented on August 18, 2024

Awesome thanks for setting this up @benmccann!

from svelte-jester.

benmccann avatar benmccann commented on August 18, 2024

I was just curious @sebastianrothe if this is something you're still planning to give a go of?

from svelte-jester.

sebastianrothe avatar sebastianrothe commented on August 18, 2024

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.

benmccann avatar benmccann commented on August 18, 2024

Looks like this will probably depend on #55. There's a PR for it though: #56

from svelte-jester.

mihar-22 avatar mihar-22 commented on August 18, 2024

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.

benmccann avatar benmccann commented on August 18, 2024

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.

mihar-22 avatar mihar-22 commented on August 18, 2024

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.

benmccann avatar benmccann commented on August 18, 2024

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.

sebastianrothe avatar sebastianrothe commented on August 18, 2024

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.

benmccann avatar benmccann commented on August 18, 2024

Yeah, that's fine. We listed jest >= 27 as a peer dependency:

https://github.com/mihar-22/svelte-jester/blob/1052bed4eb2c3c7c1cc6739ee21363de38f4f7c4/package.json#L46

from svelte-jester.

rkennel avatar rkennel commented on August 18, 2024

Yes, I am seeing same error as @gorjan-mishevski. Same jest config file

[email protected]
[email protected]
[email protected]

from svelte-jester.

ritchieanesco avatar ritchieanesco commented on August 18, 2024

+1. Also same config.

[email protected]
[email protected]
[email protected]

from svelte-jester.

benmccann avatar benmccann commented on August 18, 2024

Please use the latest version: 2.1.2

from svelte-jester.

ritchieanesco avatar ritchieanesco commented on August 18, 2024

@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.

adam-kov avatar adam-kov commented on August 18, 2024

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.

colehpage avatar colehpage commented on August 18, 2024

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)

@n00pper it was left out of the published version but is being addressed 👍
#81

from svelte-jester.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.