Skip to content

Importing libraries in setupTests.ts throws TypeScript errors #103

Description

@nareshbhatia

Current Behavior

The following imports in setupTests.ts throw Typescript errors:

import 'react-testing-library/cleanup-after-each';

The above throws "ReferenceError: afterEach is not defined"

import 'jest-dom/extend-expect';

The above throws "ReferenceError: expect is not defined"

It is as if Jest does not recognize its own globals.

The same imports work correctly in test files.

Expected behavior

Library imports should work correctly in setup files.

Additional context

Here's my repo that shows this issue: https://github.com/nareshbhatia/react-base-tsdx

Currently the above imports are in the test files, so they work correctly. Just try yarn test.

Now uncomment the same imports in setupTests.ts (one at a time) and run yarn test. You will see the errors.

Your environment

Software Version(s)
TSDX 0.5.9
TypeScript 3.4.5
Browser N/A
npm/Yarn Yarn 1.15.2
Operating System MacOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: supportAsking for support with something or a specific use casesolution: intended behaviorThis is not a bug and is expected behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions