-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
automocking: true is broken #6127
Comments
I understand that manually mocking each file is a workaround here: but I have a massive project and this is not a scalable solution. |
Could you create an actual project that someone can pull down and play with to reproduce the problem?
Maybe I'm missing something, but can you disclose fooHelper, baz, and bar? |
I got the similar error as well when I set
I was trying to use this config to avoid calling |
When I run jest with
However, Now I get the following error:
When I'm running tests. My module returns a named async function which in fact does return a promise. It works fine without having automock turned on. |
+1 |
Had anyone solved this issue? |
+1 |
This is causing a lot of issues for my project. Appreciate if anyone can update here if they find a solution. Cheers! :) |
I'm having the same problem. Here is another error that can occure:
Maybe that helps to make this issue better queryable :) |
+1 |
Perhaps under |
I am getting "TypeError: Cannot read property 'default' of undefined" from node_module which I expect to be automocked.
test import { shallowMount } from '@vue/test-utils';
import BillingProfile from './BillingProfile.vue';
jest.enableAutomock();
jest.unmock('@vue/test-utils');
jest.unmock('./BillingProfile.vue');
const wrapperFactory = (options = {}) => {
return shallowMount(BillingProfile, {
mocks: {
$route: { path: '/' },
$store: {},
},
...options,
});
};
describe('BillingProfile', () => {
it.only('renders a signup form when user is not present', () => {
const wrapper = wrapperFactory();
expect(wrapper.find('.message').text()).toEqual(
'Welcome to the Vue.js cookbook'
);
});
}); jest config module.exports = {
// preset reference: https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-plugin-unit-jest/presets/default/jest-preset.js
preset: '@vue/cli-plugin-unit-jest/presets/typescript-and-babel',
testMatch: ['**/*.spec.ts'],
moduleNameMapper: {
'^@/types$': '<rootDir>/src/types/index.d',
'^@env$': '<rootDir>/src/env/env.dev',
},
transformIgnorePatterns: ['node_modules/(?!(quasar|quasar/*|@quasar|@quasar/*))'],
}; |
+1 |
Having the same issue. Here is the error:
|
@cpojer @aaronabramov @SimenB can we shed some light on this issue, please? 😄 When using I would expect that Here's a super simple example, as requested: This works when config is const admin = require("firebase-admin");
jest.mock("firebase-admin");
test("hello", () => {
expect(true).toBe(true);
}); This breaks when { const admin = require("firebase-admin");
test("hello", () => {
expect(true).toBe(true);
}); Error:
Environment Details
Appreciate your time! |
@govindrai |
+1 |
I am having this issue as well. It happens regardless of whether I set Error message for all test suites:
I should also not the documentation pointed to by the error message does not work out of the box. I am using TypeScript and jest version |
I got this error when i enable automock: ● Test suite failed to run
|
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Running this in my tests:
Here is what my
index.js
looks likeHere is what happens when I run jest:
So given that I can't use
automocking: false
, I tried setting it to true which gives this error:Setting:
Also just presents another error:
And setting unmocking
jest-jasmine2
doesn't seem to fix it.If the current behavior is a bug, please provide the steps to reproduce and
either a repl.it demo through https://repl.it/languages/jest or a minimal
repository on GitHub that we can
yarn install
andyarn test
.run
node scripts/test.js --env=jsdom
What is the expected behavior?
Ideally I could just grab a simple enum from a file with out jest resolving everything (I have a massive app). But if that's too complicated then I would love for automock to work out of the box.
Please provide your exact Jest configuration
Run
npx envinfo --preset jest
in your project directory and paste theresults here
Thanks!
The text was updated successfully, but these errors were encountered: