From 7faad40f8be01434d396c2a7878a936055bb742e Mon Sep 17 00:00:00 2001 From: Jason Finch Date: Sun, 3 Apr 2022 14:36:13 +1000 Subject: [PATCH] chore(tests): move tests under src folder to fix jest issue --- jest.config.js | 17 +++++++++++++---- {test => src/__tests__}/index.spec.tsx | 2 +- tsconfig.json | 1 + 3 files changed, 15 insertions(+), 5 deletions(-) rename {test => src/__tests__}/index.spec.tsx (99%) diff --git a/jest.config.js b/jest.config.js index 81b3c0d18..6b16761bf 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,10 +1,18 @@ module.exports = { // The root of your source code, typically /src // `` is a token Jest substitutes - roots: ['/test'], + roots: [''], - // Jest transformations -- this adds support for TypeScript - // using ts-jest + verbose: true, + globals: { + 'ts-jest': { + diagnostics: { + warnOnly: true + } + } + }, + + // Jest transformations -- this adds support for TypeScript using ts-jest transform: { '^.+\\.tsx?$': 'ts-jest', '^.+\\.scss$': 'jest-scss-transform' @@ -24,5 +32,6 @@ module.exports = { testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$', // Module file extensions for importing - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'] + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], + preset: 'ts-jest' }; diff --git a/test/index.spec.tsx b/src/__tests__/index.spec.tsx similarity index 99% rename from test/index.spec.tsx rename to src/__tests__/index.spec.tsx index 51eedd13f..552091078 100644 --- a/test/index.spec.tsx +++ b/src/__tests__/index.spec.tsx @@ -2,7 +2,7 @@ * @jest-environment jsdom */ import React from 'react'; -import ReactTooltip from '../src/index'; +import ReactTooltip from '../index'; import { render, cleanup } from '@testing-library/react'; import forEach from 'mocha-each'; diff --git a/tsconfig.json b/tsconfig.json index 22a9d34dd..e8023521b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,7 @@ "outDir": "./out-tsc", "allowJs": true, "target": "es2018", + // "types": ["node","jest"], "module": "esnext", "moduleResolution": "node", "noImplicitAny": false,