Skip to content
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

Error: when testing with jest #82

Open
AchoArnold opened this issue Jul 16, 2020 · 0 comments
Open

Error: when testing with jest #82

AchoArnold opened this issue Jul 16, 2020 · 0 comments

Comments

@AchoArnold
Copy link

Hello,

When I try to test a mapbox componet with jest, I get the error Error in mounted hook: "ReferenceError: mapboxgl is not defined"

I've tried changing my jest config to

module.exports = {
    moduleNameMapper: {
        '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
            '<rootDir>/.jest/fileMock.js',
        mapboxgl: '<rootDir>/node_modules/mapbox-gl/dist/mapbox-gl.js',
    },
};

and even adding a jest mock but I can't get it to work

jest.mock('mapboxgl', () => ({
    Map: () => ({}),
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant