From e7b5027428fee9d0e95112cbe42794133b6657cf Mon Sep 17 00:00:00 2001 From: adil <68734155+adevinwild@users.noreply.github.com> Date: Tue, 14 Feb 2023 08:44:27 +0100 Subject: [PATCH] feat: :sparkles: Added `jest` with TypeScript support - Added a unit test for the helloWorld function --- jest.config.cjs | 5 +++++ package.json | 6 +++++- tests/helloWorld.test.ts | 7 +++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 jest.config.cjs create mode 100644 tests/helloWorld.test.ts diff --git a/jest.config.cjs b/jest.config.cjs new file mode 100644 index 0000000..869f8ad --- /dev/null +++ b/jest.config.cjs @@ -0,0 +1,5 @@ +/** @type {import('ts-jest').JestConfigWithTsJest} */ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'node', +} diff --git a/package.json b/package.json index d20ecfb..9a8b951 100644 --- a/package.json +++ b/package.json @@ -21,15 +21,19 @@ "build": "npm run clean && microbundle", "dev": "microbundle watch", "lint": "eslint ./src --ext .ts", - "clean": "rimraf dist" + "clean": "rimraf dist", + "test": "jest ./tests" }, "devDependencies": { + "@types/jest": "^29.4.0", "@typescript-eslint/eslint-plugin": "^5.52.0", "@typescript-eslint/parser": "^5.52.0", "eslint": "^8.34.0", + "jest": "^29.4.2", "microbundle": "^0.15.1", "prettier": "^2.8.4", "rimraf": "^3.0.2", + "ts-jest": "^29.0.5", "ts-node": "^10.9.1", "typescript": "^4.9.5" } diff --git a/tests/helloWorld.test.ts b/tests/helloWorld.test.ts new file mode 100644 index 0000000..aaedb60 --- /dev/null +++ b/tests/helloWorld.test.ts @@ -0,0 +1,7 @@ +import { helloWorld } from '../src' + +describe('helloWorld', () => { + it('returns "Hello World!"', () => { + expect(helloWorld()).toBe('Hello World!') + }) +})