From 3a8c7a7bf4dca171939fe2a789867f0136fa034a Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 19 Sep 2021 10:31:53 +0200 Subject: [PATCH] Added required code coverage for jest --- jest.config.js | 8 ++++++++ package.json | 5 +++-- src/{ => app}/App.scss | 2 +- src/{ => app}/App.tsx | 12 ++++++------ src/app/services/provideServices.ts | 2 +- test/{ => app}/App.test.tsx | 6 +++--- 6 files changed, 22 insertions(+), 13 deletions(-) rename src/{ => app}/App.scss (93%) rename src/{ => app}/App.tsx (83%) rename test/{ => app}/App.test.tsx (88%) diff --git a/jest.config.js b/jest.config.js index d1896e6f..d8cf9bde 100644 --- a/jest.config.js +++ b/jest.config.js @@ -8,6 +8,14 @@ module.exports = { '!src/**/provideServices.ts', '!src/container/*.ts', ], + coverageThreshold: { + global: { + branches: 80, + functions: 80, + lines: 80, + statements: 80, + }, + }, resolver: 'jest-pnp-resolver', setupFiles: [ 'react-app-polyfill/jsdom', diff --git a/package.json b/package.json index 900cc2c5..dbfd828f 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,9 @@ "serve:build": "serve ./build", "build": "node scripts/build.js", "test": "node scripts/test.js --env=jsdom --colors --verbose", - "test:ci": "npm run test -- --coverage --coverageReporters=text --coverageReporters=text-summary --coverageReporters=clover", - "test:pretty": "npm run test -- --coverage --coverageReporters=text --coverageReporters=text-summary --coverageReporters=html", + "test:coverage": "npm run test -- --coverage --coverageReporters=text --coverageReporters=text-summary", + "test:ci": "npm run test:coverage -- --coverageReporters=clover", + "test:pretty": "npm run test:coverage -- --coverageReporters=html", "mutate": "./node_modules/.bin/stryker run --concurrency 4" }, "dependencies": { diff --git a/src/App.scss b/src/app/App.scss similarity index 93% rename from src/App.scss rename to src/app/App.scss index a6566e27..538c0179 100644 --- a/src/App.scss +++ b/src/app/App.scss @@ -1,4 +1,4 @@ -@import './utils/base'; +@import '../utils/base'; .app-container { height: 100%; diff --git a/src/App.tsx b/src/app/App.tsx similarity index 83% rename from src/App.tsx rename to src/app/App.tsx index d8ac9b2a..d8b91056 100644 --- a/src/App.tsx +++ b/src/app/App.tsx @@ -1,11 +1,11 @@ import { useEffect, FC } from 'react'; import { Route, Switch } from 'react-router-dom'; -import NotFound from './common/NotFound'; -import { ServersMap } from './servers/data'; -import { Settings } from './settings/reducers/settings'; -import { changeThemeInMarkup } from './utils/theme'; -import { AppUpdateBanner } from './common/AppUpdateBanner'; -import { forceUpdate } from './utils/helpers/sw'; +import NotFound from '../common/NotFound'; +import { ServersMap } from '../servers/data'; +import { Settings } from '../settings/reducers/settings'; +import { changeThemeInMarkup } from '../utils/theme'; +import { AppUpdateBanner } from '../common/AppUpdateBanner'; +import { forceUpdate } from '../utils/helpers/sw'; import './App.scss'; interface AppProps { diff --git a/src/app/services/provideServices.ts b/src/app/services/provideServices.ts index 1564b874..4dff9f31 100644 --- a/src/app/services/provideServices.ts +++ b/src/app/services/provideServices.ts @@ -1,6 +1,6 @@ import Bottle from 'bottlejs'; import { appUpdateAvailable, resetAppUpdate } from '../reducers/appUpdates'; -import App from '../../App'; +import App from '../App'; import { ConnectDecorator } from '../../container/types'; const provideServices = (bottle: Bottle, connect: ConnectDecorator) => { diff --git a/test/App.test.tsx b/test/app/App.test.tsx similarity index 88% rename from test/App.test.tsx rename to test/app/App.test.tsx index 2ce9c408..873e70ec 100644 --- a/test/App.test.tsx +++ b/test/app/App.test.tsx @@ -1,9 +1,9 @@ import { shallow, ShallowWrapper } from 'enzyme'; import { Route } from 'react-router-dom'; import { Mock } from 'ts-mockery'; -import { Settings } from '../src/settings/reducers/settings'; -import appFactory from '../src/App'; -import { AppUpdateBanner } from '../src/common/AppUpdateBanner'; +import { Settings } from '../../src/settings/reducers/settings'; +import appFactory from '../../src/app/App'; +import { AppUpdateBanner } from '../../src/common/AppUpdateBanner'; describe('', () => { let wrapper: ShallowWrapper;