Skip to content

Commit 7b1076a

Browse files
committed
Running tests for wa-sqlite.
1 parent 3b0a76d commit 7b1076a

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

packages/driver-tests/src/driver-tests.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as fs from 'node:fs/promises';
22
import * as path from 'node:path';
3-
import { beforeEach, describe, test } from './test.js';
4-
import { expect } from 'expect';
3+
import { beforeEach, describe, test, expect } from './test.js';
54
import { SqliteDriverConnectionPool } from '@sqlite-js/driver';
65

76
export interface DriverFeatures {

packages/driver-tests/src/test.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// A lib to allow testing with vitest or mocha
2-
import type { test as testType, describe as describeType } from 'vitest';
2+
import type {
3+
test as testType,
4+
describe as describeType,
5+
expect as expectType
6+
} from 'vitest';
37

48
export interface TestContext {
59
fullName: string;
@@ -8,15 +12,19 @@ export interface TestContext {
812
export const isVitest = true || process.env.VITEST == 'true';
913
export const isMocha = !isVitest;
1014

11-
let testImpl, describeImpl, beforeEachImpl;
15+
let testImpl, describeImpl, beforeEachImpl, expectImpl;
1216

1317
if (isMocha) {
1418
const { test, describe, beforeEach } = await import('./setup-mocha.js');
19+
const { expect } = await import('expect');
20+
expectImpl = expect;
1521
testImpl = test;
1622
describeImpl = describe;
1723
beforeEachImpl = beforeEach;
1824
} else {
1925
const { test, describe, beforeEach } = await import('./setup-vitest.js');
26+
const { expect } = await import('vitest');
27+
expectImpl = expect;
2028
testImpl = test;
2129
describeImpl = describe;
2230
beforeEachImpl = beforeEach;
@@ -28,3 +36,4 @@ export function beforeEach(callback: (context: TestContext) => any) {
2836

2937
export const test = testImpl as typeof testType;
3038
export const describe = describeImpl as typeof describeType;
39+
export const expect = expectImpl as typeof expectType;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { describeDriverTests } from '@sqlite-js/driver-tests';
2+
import { waSqlitePool } from '../../lib/index.js';
3+
4+
describeDriverTests(
5+
'wa-sqlite',
6+
{ getColumns: true, rawResults: true, allowsMissingParameters: false },
7+
(path) => waSqlitePool(':memory:')
8+
);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "../../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"lib": ["ES2022", "DOM"],
5+
"noEmit": true
6+
},
7+
"include": ["src"],
8+
"references": [{ "path": "../" }]
9+
}

0 commit comments

Comments
 (0)