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

ReferenceError: jest is not defined #8802

Closed
scrodrig opened this issue Apr 19, 2024 · 1 comment
Closed

ReferenceError: jest is not defined #8802

scrodrig opened this issue Apr 19, 2024 · 1 comment
Labels

Comments

@scrodrig
Copy link

scrodrig commented Apr 19, 2024

Describe the bug

When using a node module component:

$ bit create module modules/hello-world

Steps to Reproduce

const foo= {
  bar: (a, b) => a + b,
};
 describe('fake api', () => {
      beforeEach(() => {
        jest.restoreAllMocks();
      });

      it('renders with the correct text', () => {
             const spy = jest.spyOn(foo, 'bar');
              expect(spy).toHaveBeenCalled();
        });
});

Expected Behavior

This should work and pass the test

Screenshots, exceptions and logs

The issue is that structures as it, describe, equal and so on ... works with no issue,
but when trying to use jest.spyOn or jest.restoreAllMocks(), I got:

ReferenceError: jest is not defined

Specifications

  • Bit version: 1.6.106
  • Workspace type: harmony
  • Node version: 20.12.0
  • npm version: 10.5.0
  • Platform: WSL2 Ubuntu 22.04

for harmony workspace

aspects
teambit.component/dev-files
teambit.compositions/compositions
teambit.dependencies/dependency-resolve
teambit.docs/docs
teambit.envs/envs
teambit.harmony/application
teambit.pkg/pkg
teambit.preview/preview
teambit.semantics/schema

for leagacy

  • Bit compiler (include version):
  • Bit tester (include version):

Additional context

I tried to instal jest by myself, but @bitdev/[email protected] is already provided with that installation, also install bit install @jest/globals with no luck

@itaymendel
Copy link
Contributor

the version of the env (1.0.26) is using Vitest, not Jest...
so this is the reason for your issue. if you want, you can replace the tester with Jest by creating a custom env.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants