Skip to content

Commit 6a0f31c

Browse files
Fix Unit Tests (#497)
1 parent ae0f51b commit 6a0f31c

File tree

27 files changed

+1539
-2188
lines changed

27 files changed

+1539
-2188
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ jobs:
4040
- name: Install dependencies
4141
run: pnpm install
4242

43+
- name: Configure Playwright
44+
run: |
45+
pnpm exec playwright install-deps
46+
pnpm exec playwright install
47+
4348
- name: Build
4449
run: pnpm build:packages
4550

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<a href="https://www.powersync.com" target="_blank"><img src="https://github.com/powersync-ja/.github/assets/7372448/d2538c43-c1a0-4c47-9a76-41462dba484f"/></a>
33
</p>
44

5-
*[PowerSync](https://www.powersync.com) is a sync engine for building local-first apps with instantly-responsive UI/UX and simplified state transfer. Syncs between SQLite on the client-side and Postgres, MongoDB or MySQL on the server-side.*
5+
_[PowerSync](https://www.powersync.com) is a sync engine for building local-first apps with instantly-responsive UI/UX and simplified state transfer. Syncs between SQLite on the client-side and Postgres, MongoDB or MySQL on the server-side._
66

77
# PowerSync JavaScript SDKs
88

@@ -100,6 +100,15 @@ Build packages
100100
pnpm build:packages
101101
```
102102

103+
## Tests
104+
105+
Some packages use [Playwright](https://www.npmjs.com/package/playwright) for testing. Install Playwright dependencies with:
106+
107+
```bash
108+
pnpm exec playwright install-deps
109+
pnpm exec playwright install
110+
```
111+
103112
## Versioning
104113

105114
### Development Packages

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@
3333
"@actions/core": "^1.10.1",
3434
"@changesets/cli": "2.27.2",
3535
"@pnpm/workspace.find-packages": "^4.0.2",
36+
"@vitest/browser": "^3.0.5",
3637
"husky": "^9.0.11",
3738
"lint-staged": "^15.2.2",
38-
"prettier": "^3.2.5"
39+
"playwright": "^1.50.1",
40+
"prettier": "^3.2.5",
41+
"typescript": "^5.7.2",
42+
"vitest": "^3.0.5"
3943
}
4044
}

packages/attachments/package.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,9 @@
3232
"@powersync/common": "workspace:^1.18.1"
3333
},
3434
"devDependencies": {
35+
"@powersync/common": "workspace:*",
3536
"@types/node": "^20.17.6",
36-
"@vitest/browser": "^2.1.8",
37-
"ts-loader": "^9.5.1",
38-
"ts-node": "^10.9.2",
39-
"typescript": "^5.7.2",
40-
"vite": "^5.4.11",
41-
"vite-plugin-top-level-await": "^1.4.4",
42-
"vitest": "^2.1.8",
43-
"webdriverio": "^9.4.5"
37+
"vite": "^6.1.0",
38+
"vite-plugin-top-level-await": "^1.4.4"
4439
}
4540
}

packages/attachments/vitest.config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ const config: UserConfigExport = {
1010
browser: {
1111
enabled: true,
1212
headless: true,
13-
provider: 'webdriverio',
14-
name: 'chrome' // browser name is required
13+
provider: 'playwright',
14+
instances: [
15+
{
16+
browser: 'chromium'
17+
}
18+
]
1519
}
1620
}
1721
};

packages/common/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@
5858
"rsocket-core": "1.0.0-alpha.3",
5959
"rsocket-websocket-client": "1.0.0-alpha.3",
6060
"text-encoding": "^0.7.0",
61-
"typescript": "^5.5.3",
62-
"vitest": "^2.0.5",
6361
"web-streams-polyfill": "3.2.1"
6462
}
6563
}

packages/common/src/client/sync/stream/AbstractRemote.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@ import { type fetch } from 'cross-fetch';
55
import Logger, { ILogger } from 'js-logger';
66
import { RSocket, RSocketConnector, Requestable } from 'rsocket-core';
77
import { WebsocketClientTransport } from 'rsocket-websocket-client';
8+
import PACKAGE from '../../../../package.json' with { type: 'json' };
89
import { AbortOperation } from '../../../utils/AbortOperation.js';
910
import { DataStream } from '../../../utils/DataStream.js';
1011
import { PowerSyncCredentials } from '../../connection/PowerSyncCredentials.js';
1112
import { StreamingSyncLine, StreamingSyncRequest } from './streaming-sync-types.js';
1213

13-
import { version as POWERSYNC_JS_VERSION } from '../../../../package.json';
14-
1514
export type BSONImplementation = typeof BSON;
1615

17-
const POWERSYNC_TRAILING_SLASH_MATCH = /\/+$/;
1816
export type RemoteConnector = {
1917
fetchCredentials: () => Promise<PowerSyncCredentials | null>;
2018
};
2119

20+
const POWERSYNC_TRAILING_SLASH_MATCH = /\/+$/;
21+
const POWERSYNC_JS_VERSION = PACKAGE.version;
22+
2223
// Refresh at least 30 sec before it expires
2324
const REFRESH_CREDENTIALS_SAFETY_PERIOD_MS = 30_000;
2425
const SYNC_QUEUE_REQUEST_LOW_WATER = 5;

packages/common/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"outDir": "./lib",
99
"lib": ["esnext"],
1010
"declaration": true,
11-
"module": "node16",
12-
"moduleResolution": "node16",
11+
"module": "NodeNext",
12+
"moduleResolution": "nodenext",
1313
"preserveConstEnums": true,
1414
"esModuleInterop": false,
1515
"skipLibCheck": false,

packages/drizzle-driver/package.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,9 @@
3333
"@powersync/web": "workspace:*",
3434
"@journeyapps/wa-sqlite": "^1.2.0",
3535
"@types/node": "^20.17.6",
36-
"@vitest/browser": "^2.1.4",
3736
"drizzle-orm": "^0.35.2",
38-
"ts-loader": "^9.5.1",
39-
"ts-node": "^10.9.2",
40-
"typescript": "^5.6.3",
41-
"vite": "^5.4.10",
37+
"vite": "^6.1.0",
4238
"vite-plugin-top-level-await": "^1.4.4",
43-
"vite-plugin-wasm": "^3.3.0",
44-
"vitest": "^2.1.4",
45-
"webdriverio": "^9.2.8"
39+
"vite-plugin-wasm": "^3.3.0"
4640
}
4741
}

packages/drizzle-driver/vitest.config.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import wasm from 'vite-plugin-wasm';
21
import topLevelAwait from 'vite-plugin-top-level-await';
2+
import wasm from 'vite-plugin-wasm';
33
import { defineConfig, UserConfigExport } from 'vitest/config';
44

55
const config: UserConfigExport = {
@@ -20,8 +20,12 @@ const config: UserConfigExport = {
2020
browser: {
2121
enabled: true,
2222
headless: true,
23-
provider: 'webdriverio',
24-
name: 'chrome' // browser name is required
23+
provider: 'playwright',
24+
instances: [
25+
{
26+
browser: 'chromium'
27+
}
28+
]
2529
}
2630
}
2731
};

0 commit comments

Comments
 (0)