Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Commit 10d7eae

Browse files
authored
feat(test): Automate smoke tests for JS Client [DXJ-293] (#282)
1 parent 3fbeb0d commit 10d7eae

40 files changed

+830
-169
lines changed

package.json

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
{
2-
"name": "common-dev-deps",
3-
"version": "0.1.0",
4-
"main": "./dist/index.js",
5-
"typings": "./dist/index.d.ts",
6-
"type": "module",
7-
"engines": {
8-
"node": ">=10",
9-
"pnpm": ">=3"
10-
},
11-
"scripts": {
12-
"simulate-cdn": "http-server -p 8765 ./packages/client/js-client.web.standalone/dist"
13-
},
14-
"author": "Fluence Labs",
15-
"license": "Apache-2.0",
16-
"devDependencies": {
17-
"http-server": "14.1.1",
18-
"@types/node": "18.13.0",
19-
"ts-node": "10.9.1",
20-
"typescript": "4.7",
21-
"@fluencelabs/aqua-lib": "0.6.0",
22-
"@fluencelabs/aqua": "0.9.1-374"
23-
}
2+
"name": "common-dev-deps",
3+
"version": "0.1.0",
4+
"main": "./dist/index.js",
5+
"typings": "./dist/index.d.ts",
6+
"type": "module",
7+
"engines": {
8+
"node": ">=10",
9+
"pnpm": ">=3"
10+
},
11+
"scripts": {
12+
"simulate-cdn": "http-server -p 8765 ./packages/client/js-client.web.standalone/dist"
13+
},
14+
"author": "Fluence Labs",
15+
"license": "Apache-2.0",
16+
"devDependencies": {
17+
"http-server": "14.1.1",
18+
"puppeteer": "19.7.2",
19+
"@types/node": "18.13.0",
20+
"ts-node": "10.9.1",
21+
"typescript": "4.7",
22+
"@fluencelabs/aqua-lib": "0.6.0",
23+
"@fluencelabs/aqua": "0.9.1-374"
24+
}
2425
}

packages/@tests/aqua/src/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import { Fluence } from '@fluencelabs/js-client.api';
33
import { kras, randomKras } from '@fluencelabs/fluence-network-environment';
44
import { registerHelloWorld, smokeTest } from './_aqua/smoke_test.js';
55

6+
// Relay running on local machine
67
// const relay = {
78
// multiaddr: '/ip4/127.0.0.1/tcp/4310/ws/p2p/12D3KooWKEprYXUXqoV5xSBeyqrWLpQLLH4PXfvVkDJtmcqmh5V3',
89
// peerId: '12D3KooWKEprYXUXqoV5xSBeyqrWLpQLLH4PXfvVkDJtmcqmh5V3',
910
// };
1011

12+
// Currently the tests executes some calls to registry. And they fail for a single local node setup. So we use kras instead.
1113
const relay = randomKras();
1214

1315
function generateRandomUint8Array() {
@@ -27,7 +29,9 @@ const optsWithRandomKeyPair = () => {
2729
} as const;
2830
};
2931

30-
export const main = async () => {
32+
export type TestResult = { res: string | null; errors: string[]; hello: string };
33+
34+
export const runTest = async (): Promise<TestResult> => {
3135
try {
3236
Fluence.onConnectionStateChange((state) => console.info('connection state changed: ', state));
3337

@@ -58,6 +62,8 @@ export const main = async () => {
5862
} else {
5963
console.log('aqua finished, result', res);
6064
}
65+
66+
return { res, errors, hello };
6167
} finally {
6268
console.log('disconnecting from Fluence Network...');
6369
await Fluence.disconnect();
@@ -66,7 +72,7 @@ export const main = async () => {
6672
};
6773

6874
export const runMain = () => {
69-
main()
75+
runTest()
7076
.then(() => console.log('done!'))
7177
.catch((err) => console.error('error: ', err));
7278
};

packages/@tests/frameworks/cra-ts/src/App.tsx

Lines changed: 0 additions & 26 deletions
This file was deleted.

packages/@tests/frameworks/cra-ts/tsconfig.json

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"type": "module",
1212
"scripts": {
1313
"build": "tsc",
14-
"_test": "node --loader ts-node/esm ./src/index.ts"
14+
"test": "node --loader ts-node/esm ./src/index.ts"
1515
},
1616
"repository": "https://github.com/fluencelabs/fluence-js",
1717
"author": "Fluence Labs",
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import '@fluencelabs/js-client.node';
2+
import { runTest } from '@test/aqua_for_test';
3+
4+
runTest().then(() => console.log('Smoke tests succeed!'));
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "../../../../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "./dist"
5+
},
6+
"exclude": ["node_modules", "dist"]
7+
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)