testing with jest
This commit is contained in:
parent
9ed0a19393
commit
c43bff3e15
19
jest.config.ts
Normal file
19
jest.config.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import type { JestConfigWithTsJest } from "ts-jest"
|
||||||
|
|
||||||
|
const config: JestConfigWithTsJest = {
|
||||||
|
verbose: true,
|
||||||
|
transform: {
|
||||||
|
"^.+\\.ts?$": [
|
||||||
|
"ts-jest",
|
||||||
|
{
|
||||||
|
useESM: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
extensionsToTreatAsEsm: [".ts"],
|
||||||
|
moduleNameMapper: {
|
||||||
|
"^(\\.{1,2}/.*)\\.js$": "$1",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export default config
|
19
package.json
19
package.json
@ -5,23 +5,28 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node --import=tsx ./src/main.ts | pino-pretty",
|
"start": "node --import=tsx ./src/main.ts | pino-pretty",
|
||||||
"test": "node --test --experimental-strip-types ./tests/**",
|
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
||||||
"format": "prettier --write \"./**/*.{js,mjs,ts,md,json}\""
|
"format": "prettier --write \"./**/*.{js,mjs,ts,md,json}\""
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actual-app/api": "^24.11.0",
|
"@actual-app/api": "^24.12.0",
|
||||||
"cron": "^3.2.1",
|
"cron": "^3.3.1",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.4.7",
|
||||||
"pino": "^9.5.0",
|
"pino": "^9.5.0",
|
||||||
"prettier": "^3.3.3"
|
"prettier": "^3.4.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^22.9.0",
|
"@jest/globals": "^29.7.0",
|
||||||
|
"@types/jest": "^29.5.14",
|
||||||
|
"@types/node": "^22.10.2",
|
||||||
|
"jest": "^29.7.0",
|
||||||
|
"ts-jest": "^29.2.5",
|
||||||
|
"ts-node": "^10.9.2",
|
||||||
"tsx": "^4.19.2",
|
"tsx": "^4.19.2",
|
||||||
"typescript": "^5.6.3"
|
"typescript": "^5.7.2"
|
||||||
},
|
},
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"semi": false,
|
"semi": false,
|
||||||
|
2696
pnpm-lock.yaml
generated
2696
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,12 @@
|
|||||||
import { describe, it } from "node:test"
|
import { describe, expect, it } from "@jest/globals"
|
||||||
|
|
||||||
import { daily } from "@/main.ts"
|
import { daily } from "@/main.ts"
|
||||||
import { ActualImpl } from "@/actual.ts"
|
import { ActualImpl } from "@/actual.ts"
|
||||||
import { BankStub } from "./stubs/bankStub.ts"
|
import { BankStub } from "./stubs/bankStub.ts"
|
||||||
import assert from "node:assert"
|
|
||||||
|
|
||||||
describe("Main logic of the application", () => {
|
describe("Main logic of the application", () => {
|
||||||
it("should import the transactions to Actual Budget", async () => {
|
it("should import the transactions to Actual Budget", async () => {
|
||||||
await daily(await ActualImpl.init(), new BankStub())
|
await daily(await ActualImpl.init(), new BankStub())
|
||||||
assert.ok(true)
|
expect(true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
{
|
{
|
||||||
|
"include": [
|
||||||
|
"./src/**/*.ts",
|
||||||
|
"./tests/**/*.ts"
|
||||||
|
],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
@ -8,11 +12,15 @@
|
|||||||
"strict": true,
|
"strict": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"allowImportingTsExtensions": true,
|
"allowImportingTsExtensions": true,
|
||||||
"verbatimModuleSyntax": true,
|
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": [
|
"@/*": [
|
||||||
"./src/*"
|
"./src/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"./*.ts",
|
||||||
|
"__test__"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user