GithubHelp home page GithubHelp logo

Comments (10)

jboler avatar jboler commented on April 27, 2024 11

Fixed it. Just had to move the jest config into package.json:

  "jest": {
    "transformIgnorePatterns": [
      "<rootDir>/node_modules/(?!d3)/"
    ]
  },

from d3-interpolate.

Fil avatar Fil commented on April 27, 2024 3

Yes. Please check if the Jest section in https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c answers the use case? (linked from https://github.com/d3/d3-interpolate/releases/tag/v3.0.0).

from d3-interpolate.

matiasfacio avatar matiasfacio commented on April 27, 2024 2

same here @matiasfacio do you have any fix?

I kind of found a workaround for my case. I am using ant-design which uses 3d. I mocked the imports of the components using the library in the test file that was throwing the error... shame on me, but couldn't do it otherwise.

jest.mock('@ant-design/plots', () => ({
Column: () => null,
ColumnConfig: () => null,
}));

from d3-interpolate.

matiasfacio avatar matiasfacio commented on April 27, 2024 1

hi!

I still have this problem, but this time use ant design and running jest.
Do you know how to solve it??

` Details:

/Users/work-dashboard/node_modules/@antv/g-base/node_modules/d3-interpolate/src/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export { default as interpolate } from "./value.js";
                                                                                  ^^^^^^

SyntaxError: Unexpected token 'export'`

Thanks for any hint!

By the way, the other solutions did not help me.

from d3-interpolate.

slaweet avatar slaweet commented on April 27, 2024

@Fil thank you for the hint.

If anyone stumbles upon this issue, the specific solution that works for me is:

// jest.config.js
moudle.exports = {
  <other_configs_in_this_file>,

  transformIgnorePatterns: [                                                                            
    '/node_modules/(?!d3-(interpolate|color))',                                                      
  ],
};

In particular beware that if you try only '/node_modules/(?!d3-interpolate)', you'll get the SyntaxError: Unexpected token 'export' error happening in d3-color, which is IMO quite tricky to spot that it's not still the same error.

from d3-interpolate.

jboler avatar jboler commented on April 27, 2024

I'm also seeing this:

    Details:

    /Users/me/app/node_modules/d3/src/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export * from "d3-array";
                                                                                             ^^^^^^
    SyntaxError: Unexpected token 'export'

    > 1 | import { BaseType, Selection, Transition, select } from 'd3';

I tried your suggestion @slaweet but it makes no difference. I'm putting the config in craco.config.js because I'm using create-react-app:

  jest: {
    configure: {
      moduleNameMapper: {
        '@/(.*)$': '<rootDir>/src/$1',
      },
      transformIgnorePatterns: ['<rootDir>/node_modules/(?!d3)'],
    },
  },

from d3-interpolate.

jboler avatar jboler commented on April 27, 2024

Forgot to add that my project is written in Typescript including the Jest tests.

from d3-interpolate.

juztinlazaro avatar juztinlazaro commented on April 27, 2024

same here @matiasfacio do you have any fix?

from d3-interpolate.

juztinlazaro avatar juztinlazaro commented on April 27, 2024

any solution? still problematic

from d3-interpolate.

mswezey23 avatar mswezey23 commented on April 27, 2024

I ran into this as well.

Project initially was: CRA, TS, Nivo, Chakra, Jest
Then went from CRA -> Craco.

Then, WIP, Craco -> Vite.

Here's what solve it for me:

  transformIgnorePatterns: ['/node_modules/(?!d3-(interpolate|color|scale|array|format|time)|internmap)'],

from d3-interpolate.

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.