Skip to content

Commit 810f187

Browse files
committed
adjusting test setup and adding a basic test which we can start to add to
1 parent e580ac6 commit 810f187

File tree

7 files changed

+33
-13
lines changed

7 files changed

+33
-13
lines changed

core/.env.test

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
TEST_DATABASE_CLIENT=sqlite
2+
NODE_ENV=test

core/jest.config.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
/** @type {import('ts-jest').JestConfigWithTsJest} */
22
export default {
33
preset: "ts-jest",
4-
testEnvironment: "jest-environment-node",
4+
testEnvironment: "node",
55
rootDir: "./src",
66
testMatch: ["**/*.test.ts"],
7+
setupFilesAfterEnv: ["<rootDir>/test_resources/testSetup.ts"],
8+
testTimeout: 120000,
79
globals: {
810
__DEV__: true,
911
__TEST__: true,
1012
__VERSION__: "0.0.1",
1113
},
12-
// collectCoverage: true,
13-
// collectCoverageFrom: ["**/*.{ts}", "!**/*.test.{ts}", "!**/node_modules/**", "!**/vendor/**"],
14-
// coverageDirectory: "../coverage",
1514
transform: {
1615
"^.+\\.tsx?$": [
1716
"ts-jest",
@@ -24,4 +23,4 @@ export default {
2423
"^(\\.{1,2}/.*)\\.js$": "$1",
2524
},
2625
extensionsToTreatAsEsm: [".ts"],
27-
};
26+
}

core/package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
"dev": "tsc && nodemon",
3030
"build:docs": "cd docs && pnpm run build",
3131
"postinstall": "npx playwright install-deps && npx playwright install",
32-
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --runInBand --watch -f",
33-
"test:sqlite": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" TEST_DATABASE_CLIENT=sqlite jest --runInBand --watch -f",
34-
"test:sqljs": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" TEST_DATABASE_CLIENT=sqljs jest --runInBand --watch -f"
32+
"test": "jest --runInBand",
33+
"test:watch": "jest --runInBand --watch",
34+
"test:sqlite": "cross-env TEST_DATABASE_CLIENT=sqlite jest --runInBand --watch",
35+
"test:sqljs": "cross-env TEST_DATABASE_CLIENT=sqljs jest --runInBand --watch"
3536
},
3637
"author": "",
3738
"license": "MIT",

core/src/test_resources/basic.test.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
describe('Basic Test Suite', () => {
2+
it('should run a basic test', () => {
3+
expect(true).toBe(true);
4+
});
5+
6+
it('should have access to environment variables', () => {
7+
expect(process.env.NODE_ENV).toBe('test');
8+
expect(process.env.TEST_DATABASE_CLIENT).toBe('sqlite');
9+
});
10+
});

core/src/test_resources/testSetup.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import dotenv from "dotenv";
2+
import path from 'path';
3+
4+
// Load test environment variables
5+
dotenv.config({ path: '.env.test' });
6+
7+
// Set longer timeout for tests
8+
jest.setTimeout(120000);

core/tsconfig.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"compilerOptions": {
3-
"target": "es2022",
4-
"module": "es2022",
5-
"lib": ["es2023", "dom"],
6-
"moduleResolution": "bundler",
3+
"target": "ESNext",
4+
"module": "NodeNext",
5+
"lib": ["ESNext", "dom"],
6+
"moduleResolution": "NodeNext",
77
"outDir": "./dist",
88
"rootDir": "./src",
99
"strict": false,

pnpm-lock.yaml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)