@rpcbase/test 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/cli.js +23 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpcbase/test",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"bin": {
|
|
5
5
|
"rb-test": "./src/cli.js"
|
|
6
6
|
},
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@playwright/test": "1.
|
|
34
|
+
"@playwright/test": "1.49.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {}
|
|
37
37
|
}
|
package/src/cli.js
CHANGED
|
@@ -1,32 +1,42 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const path = require("path")
|
|
2
|
+
const { test } = require('@playwright/test');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
6
5
|
|
|
7
6
|
async function runTests() {
|
|
8
7
|
try {
|
|
8
|
+
// Determine config file path
|
|
9
9
|
const configPath = fs.existsSync(path.join(process.cwd(), 'playwright.config.ts'))
|
|
10
10
|
? path.join(process.cwd(), 'playwright.config.ts')
|
|
11
11
|
: path.join(__dirname, 'playwright.config.ts');
|
|
12
12
|
|
|
13
|
-
//
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
// Import the config file
|
|
14
|
+
const config = require(configPath);
|
|
15
|
+
|
|
16
|
+
// Create a test runner
|
|
17
|
+
const { _runTests } = test;
|
|
18
|
+
|
|
19
|
+
// Run the tests with the configuration
|
|
20
|
+
const testResult = await _runTests({
|
|
21
|
+
config,
|
|
22
|
+
configFile: configPath,
|
|
23
|
+
// Add any additional options you need
|
|
24
|
+
workers: config.workers || 1,
|
|
25
|
+
timeout: config.timeout || 30000,
|
|
19
26
|
});
|
|
20
27
|
|
|
21
|
-
if (
|
|
28
|
+
if (testResult.status === 'passed') {
|
|
22
29
|
console.log('All tests passed!');
|
|
23
30
|
process.exit(0);
|
|
24
|
-
} else {
|
|
31
|
+
} else if (testResult.status === 'failed') {
|
|
25
32
|
console.error('Tests failed!');
|
|
26
33
|
process.exit(1);
|
|
34
|
+
} else if (testResult.status === 'timedout') {
|
|
35
|
+
console.error('Tests timed out!');
|
|
36
|
+
process.exit(1);
|
|
27
37
|
}
|
|
28
38
|
} catch (error) {
|
|
29
|
-
console.error('Error:', error);
|
|
39
|
+
console.error('Error running tests:', error);
|
|
30
40
|
process.exit(1);
|
|
31
41
|
}
|
|
32
42
|
}
|