Coder Social home page Coder Social logo

Comments (12)

niedzielski avatar niedzielski commented on May 19, 2024 2

@kulshekhar, sorry for the late response. The import issue appeared at the time to come from a missing transform field in my config. The transform issue was difficult to track down because I appeared to be seeing a new issue that when the config changed, either through a different file via--config or when a consistently named config file itself changed, that the cache didn't invalidate. I had planned to report the caching config issue as a standalone bug but unfortunately I can no longer reproduce it. For now, I apologize for the noise and will file a ticket if I can reproduce it again.

from ts-jest.

niedzielski avatar niedzielski commented on May 19, 2024 1

First time user here. I seemed to have had a similar (?) issue with imports when I accidentally mangled my Jest config to omit transform. What really bit was me that the cache doesn't invalidate when the config changes. You can really test your config by disabling it, jest --no-cache. You can check out the recommended example config here. I found the import token error quite cryptic.

from ts-jest.

Igmat avatar Igmat commented on May 19, 2024

What version of node you are using? And why do you use "jsx": "preserve"?

from ts-jest.

dziamid avatar dziamid commented on May 19, 2024

@Igmat, sorry, forgot to mention, updated the question. By setting jsx=preserve i tell typescript to not handle jsx transpilation and let babel do the job. For some reason it works faster than letting typescript transpile it all into es2015.

from ts-jest.

Igmat avatar Igmat commented on May 19, 2024

It's strange that it shows Unexpected token import error.
Could you please share a repro? I have some thoughts but have to check them first.

from ts-jest.

dziamid avatar dziamid commented on May 19, 2024

@Igmat here you go https://github.com/dziamid/react-typescript-boilerplate

from ts-jest.

dziamid avatar dziamid commented on May 19, 2024

@Igmat did you have a change to have a look at my repro? Just in case: npm install & npm test to reproduce the proplem - it should fail on the first test with Unexpected token import error.

from ts-jest.

Igmat avatar Igmat commented on May 19, 2024

@dziamid, sorry, I was too busy at this weekend. I'll take a look and will answer tomorrow.

from ts-jest.

Igmat avatar Igmat commented on May 19, 2024

@dziamid, first of all, problem isn't in ATL. Actually webpack and its loaders aren't executed while testing.

First problem is caused by setupTestFrameworkScriptFile, so could you please tell me why do you need test-bundler.js? If you use it for coverage, then better option would be to use
"testResultsProcessor": "<rootDir>/node_modules/ts-jest/coverageprocessor.js" and --no-cache flag.

Second problem is caused by "jsx": "preserve" - currently we don't support it. I'll take a closer look on it but it seems that Jest logic doesn't support using several transformers for one file, so we have only two possible solutions - creating feature request in Jest and adding babel transpilation inside ts-jest, but seconds seems to cause a lot of issues, because I'm not sure that we will be able to correctly reflect user's babel config, and after all it not very good to make one package responsible for several transpilations.

Third problem is caused by your import statement in several files. Syntax like this:

import H1 from 'components/H1';

doesn't seem to be supported by jest-resolve, but I'll try to figure out what we can do with it in ts-jest.

P.S.
After fixing above problems in your config, not all tests will pass, but it seems to happen because of incorrect tests or implementation.

from ts-jest.

Igmat avatar Igmat commented on May 19, 2024

Ok, while here is no responses, I think my last comment helped you to fix it. I'll create related TODO issues in order to find a workaround and may be even provide some changes to ts-jest in order to solve problems with "jsx": "preserve" and this type of import statements.

from ts-jest.

Igmat avatar Igmat commented on May 19, 2024

Closing this due to #63 and #64 as more accurate issues.

from ts-jest.

kulshekhar avatar kulshekhar commented on May 19, 2024

@niedzielski I'm slightly confused. Is the issue about the import token error or cache invalidation?

from ts-jest.

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.