From 4c666c1666185b3df06875e406919705f3fe3e91 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 18 Dec 2021 11:16:15 +0100 Subject: [PATCH] Fix unittesting after cypress addition --- .github/workflows/ci.yml | 6 +++--- jest.config.js | 6 ++++++ package.json | 5 +++-- tests/tsconfig.json | 12 ++++++++++++ tests/unit/formatters.spec.ts | 7 +++++++ tsconfig.json | 9 ++++----- 6 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 tests/tsconfig.json create mode 100644 tests/unit/formatters.spec.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e43e7e6..2b344a17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,8 +31,8 @@ jobs: - name: Run type check run: yarn check-types - # - name: Run Tests - # run: yarn test:unit + - name: Run Tests + run: yarn test:unit # - name: Cypress run # uses: cypress-io/github-action@v2 @@ -40,7 +40,7 @@ jobs: # build: yarn build # start: yarn start - - name: Run Component tests 🧪 + - name: Run Component tests uses: cypress-io/github-action@v2 with: # we have already installed everything diff --git a/jest.config.js b/jest.config.js index beaf54d9..ef40233b 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,3 +1,9 @@ module.exports = { preset: '@vue/cli-plugin-unit-jest/presets/typescript-and-babel', + // testMatch: ['**/tests/unit/**/*.test.[jt]s?(x)'], + globals: { + 'ts-jest': { + tsConfig: 'tests/tsconfig.json', + }, + }, }; diff --git a/package.json b/package.json index 4287f4ba..2e713ccf 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,9 @@ "lint": "vue-cli-service lint", "check-types": "tsc --noemit", "lint-ci": "vue-cli-service lint --no-fix", - "cypress:open": "cypress open", - "cypress:run-ct": "cypress run-ct" + "cy:open": "cypress open", + "cy:open-ct": "cypress open-ct", + "cy:run-ct": "cypress run-ct" }, "dependencies": { "@cypress/vue": "^2.2.3", diff --git a/tests/tsconfig.json b/tests/tsconfig.json new file mode 100644 index 00000000..47f58e5b --- /dev/null +++ b/tests/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "types": [ + "jest", + ], + }, + "include": [ + "unit/*.ts", + "unit/*.tsx" + ], +} diff --git a/tests/unit/formatters.spec.ts b/tests/unit/formatters.spec.ts new file mode 100644 index 00000000..97192581 --- /dev/null +++ b/tests/unit/formatters.spec.ts @@ -0,0 +1,7 @@ +import { formatPercent } from '@/shared/formatters'; + +describe('formatters.ts', () => { + it('Format percent correctly', () => { + expect(formatPercent(0.5)).toEqual('50.000%'); + }); +}); diff --git a/tsconfig.json b/tsconfig.json index 65e9e379..67f95399 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,7 +15,7 @@ "baseUrl": "src", "types": [ "webpack-env", - "jest", + // "jest", "cypress" ], "paths": { @@ -28,10 +28,9 @@ "src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", - "tests/**/*.ts", - "tests/**/*.tsx" ], - "exclude": [ - "node_modules" + "exclude": [ + "node_modules", + // "tests" ] }