Skip to content

Commit 12cbfb2

Browse files
authored
Merge pull request #61 from Blitzapps/migrate-vitest
fix: vitest
2 parents d1ec85d + cd6a0d7 commit 12cbfb2

18 files changed

Lines changed: 51 additions & 17 deletions

File tree

.husky/pre-commit

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/usr/bin/env sh
2-
. "$(dirname -- "$0")/_/husky.sh"
3-
4-
pnpm precommit
1+
pnpm test

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
📝 following beta format X.Y.Z where Y = breaking change and Z = feature and fix. Later => FAIL.FEATURE.FIX
44

5+
6+
## 0.10.2(2024-04-18)
7+
8+
- Test: Migrated to vitest
9+
- Test: TypeDB url moved as env var
10+
511
## 0.10.1(2024-04-17)
612

713
- Feat: Transformations for mutations with $fields included.

package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@blitznocode/blitz-orm",
3-
"version": "0.10.1",
3+
"version": "0.10.2",
44
"main": "dist/index.cjs",
55
"module": "./dist/index.mjs",
66
"types": "dist/index.d.ts",
@@ -16,7 +16,7 @@
1616
"build": "tsup src/index.ts --format cjs,esm --clean --dts --treeshake --minify",
1717
"dev": "tsup --dts --watch --sourcemap",
1818
"knip": "knip",
19-
"husky:prepare": "husky install",
19+
"husky:prepare": "husky init",
2020
"lint:check": "eslint src --quiet --ext .ts,.tsx",
2121
"lint:fix": "eslint src --ext .ts,.tsx --fix",
2222
"lint-staged": "lint-staged",
@@ -27,13 +27,14 @@
2727
"test:query": "./tests/test.sh query.test.ts",
2828
"test:typedb-query": "./tests/test.sh typedb/unit/queries",
2929
"test:typedb-mutation": "./tests/test.sh typedb/unit/mutations",
30-
"test:typedb-ignoreTodo": "./tests/test.sh -t \"^(?!.*TODO:).*\" --detectOpenHandles typedb",
30+
"test:typedb-ignoreTodo": "vitest typedb -t \"^(?!.*TODO:).*\" ",
3131
"test:surrealdb-query": "./tests/test.sh surrealdb/unit/queries/query.test.ts",
3232
"test:multidb": "./tests/test.sh --detectOpenHandles multidb",
3333
"test:ignoreTodo": "./tests/test.sh -t \"^(?!.*TODO:).*\" --detectOpenHandles",
3434
"test:buildSchema": "npx esbuild tests/mocks/buildSchema.ts --bundle --loader:.ts=ts --platform=node --format=cjs --outfile=tests/mocks/buildSchema.js && node tests/mocks/buildSchema.js",
3535
"test:watch": "./tests/test.sh --watch",
36-
"types": "tsc --noEmit"
36+
"types": "tsc --noEmit",
37+
"prepare": "husky"
3738
},
3839
"private": false,
3940
"license": "AGPL-3.0-only",
@@ -54,14 +55,16 @@
5455
"dependencies": {
5556
"acorn": "^8.11.3",
5657
"case-anything": "^2.1.13",
58+
"dotenv": "^16.4.5",
5759
"immer": "10.0.4",
58-
"nanoid": "3",
60+
"nanoid": "^5.0.7",
5961
"object-traversal": "^1.0.1",
6062
"radash": "^11.0.0",
6163
"robot3": "^0.4.1",
6264
"surrealdb.node": "^0.3.0",
6365
"typedb-driver": "2.26.6-rc1",
64-
"uuid": "^9.0.1"
66+
"uuid": "^9.0.1",
67+
"vitest": "^1.5.0"
6568
},
6669
"devDependencies": {
6770
"@blitznocode/eslint-config": "^1.1.0",

src/stateMachine/query/tql/parse.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ const parseObj = (res: any, rawBqlRequest: RawBQLQuery, schema: EnrichedBormSche
6161
const parsedDataFields = parseDataFields(dataFields, currentSchema, config);
6262
const parsedLinkFields = parseLinkFields(linkFields, schema, config);
6363
const parsedRoleFields = parseRoleFields(roleFields, schema, config);
64-
console.log('parseObj/parsedLinkFields', JSON.stringify(parsedLinkFields));
65-
console.log('parseObj/parsedRoleFields', JSON.stringify(parsedRoleFields));
64+
//console.log('parseObj/parsedLinkFields', JSON.stringify(parsedLinkFields));
65+
//console.log('parseObj/parsedRoleFields', JSON.stringify(parsedRoleFields));
6666
const idNotIncluded = rawBqlRequest?.$fields?.every(
6767
(field) => !currentSchema?.idFields?.includes(typeof field === 'string' ? field : field.$path),
6868
);

tests/helpers/createTest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'jest';
22

33
import BormClient from "../../src";
44
import { assertDefined } from '../../src/helpers';
5+
import { afterAll, beforeAll, describe } from 'vitest';
56

67
type TestContext = {
78
query: BormClient['query'];

tests/helpers/matchers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { produce } from 'immer';
44
import type { TraversalCallbackContext } from 'object-traversal';
55
import { traverse } from 'object-traversal';
6+
import { expect } from 'vitest';
67

78
const getCommonKey = (obj1: Record<string, any>, obj2: Record<string, any>): string | undefined => {
89
const keys1 = Object.keys(obj1);

tests/multidb/mocks/config.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
import type { BormConfig } from '../../../src/index';
2+
import dotenv from 'dotenv';
3+
dotenv.config();
4+
5+
// eslint-disable-next-line turbo/no-undeclared-env-vars
6+
const typeDbUrl = process.env.TYPE_DB_URL as string;
7+
if (!typeDbUrl) {
8+
throw new Error('TYPE_DB_URL is not defined');
9+
}
210

311
export const config: BormConfig = {
412
server: {
@@ -9,16 +17,16 @@ export const config: BormConfig = {
917
id: 'typeDB',
1018
provider: 'typeDB',
1119
dbName: 'multi_db_test',
12-
url: 'localhost:1729',
20+
url: typeDbUrl,
1321
},
1422
{
1523
id: 'surrealDB',
1624
provider: 'surrealDB',
17-
namespace: 'multi_db_test',
25+
namespace: 'multi_db_test',
1826
dbName: 'test',
1927
url: 'ws://127.0.0.1:8000',
20-
username: 'tester',
21-
password: 'tester'
28+
username: 'tester',
29+
password: 'tester',
2230
},
2331
],
2432
};

tests/multidb/unit/queries/query.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'jest';
33
import { init } from '../../helpers/lifecycle';
44
import type BormClient from '../../../../src/index';
55
import { deepSort } from '../../../helpers/matchers';
6+
import { afterAll, beforeAll, describe } from 'vitest';
67

78
describe('Query', () => {
89
let cleanup: () => Promise<void>;

tests/typedb/mocks/config.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
import type { BormConfig } from '../../../src/index';
2+
import dotenv from 'dotenv';
3+
dotenv.config();
4+
5+
// eslint-disable-next-line turbo/no-undeclared-env-vars
6+
const typeDbUrl = process.env.TYPE_DB_URL as string;
7+
if (!typeDbUrl) {
8+
throw new Error('TYPE_DB_URL is not defined');
9+
}
210

311
export const config: BormConfig = {
412
server: {
@@ -9,7 +17,7 @@ export const config: BormConfig = {
917
id: 'default',
1018
provider: 'typeDB',
1119
dbName: 'test',
12-
url: 'localhost:1729',
20+
url: typeDbUrl,
1321
},
1422
],
1523
};

tests/unit/mutations/basic.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { v4 as uuidv4 } from 'uuid';
33

44
import { deepSort, expectArraysInObjectToContainSameElements } from '../../helpers/matchers';
55
import { createTest } from '../../helpers/createTest';
6+
import { expect, it } from 'vitest';
67

78
export const testBasicMutation = createTest('Mutation: Basic', (ctx) => {
89
// some random issues forced a let here

0 commit comments

Comments
 (0)