qa 0.0.7 → 0.0.8
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/dist/commands/test.js +31 -14
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +5 -2
- package/package.json +1 -1
package/dist/commands/test.js
CHANGED
|
@@ -4,7 +4,7 @@ import WebSocket from 'ws';
|
|
|
4
4
|
import { getAuthenticatedClient } from '@codeless.qa/contracts/client';
|
|
5
5
|
import { pullTestSuite } from '../api.js';
|
|
6
6
|
import { getAccessToken } from '../auth.js';
|
|
7
|
-
import { CLI_EPILOGUE,
|
|
7
|
+
import { CLI_EPILOGUE, WORKER_URL } from '../constants.js';
|
|
8
8
|
const SUPPORTED_REPORTER = [
|
|
9
9
|
'classic', 'doc', 'dot', 'dump', 'json', 'jsonstream', 'landing',
|
|
10
10
|
'list', 'markdown', 'min', 'nyan', 'progress', 'silent', 'spec',
|
|
@@ -41,18 +41,15 @@ export const builder = (yargs) => {
|
|
|
41
41
|
export const handler = async (argv) => {
|
|
42
42
|
const token = await getAccessToken(argv.token);
|
|
43
43
|
const client = getAuthenticatedClient(token);
|
|
44
|
-
// console.log('Running test on project', argv.project)
|
|
45
44
|
const reporter = argv.reporter;
|
|
46
45
|
if (!SUPPORTED_REPORTER.includes(reporter)) {
|
|
47
46
|
throw new Error(`Reporter ${argv.reporter} is not supported, please select one of the following: ${SUPPORTED_REPORTER.join(', ')}`);
|
|
48
47
|
}
|
|
49
48
|
const { testplan, specification } = await pullTestSuite(client, argv.project);
|
|
50
|
-
const workerUrl =
|
|
51
|
-
// console.log(`Connecting with worker at ${workerUrl}`)
|
|
49
|
+
const workerUrl = `${WORKER_URL}/session`;
|
|
52
50
|
const ws = new WebSocket(workerUrl);
|
|
53
|
-
ws.on('error', console.error);
|
|
54
51
|
ws.on('open', function open() {
|
|
55
|
-
|
|
52
|
+
console.log(`Connected to worker at ${workerUrl}`);
|
|
56
53
|
const payload = {
|
|
57
54
|
type: 0,
|
|
58
55
|
value: {
|
|
@@ -62,20 +59,40 @@ export const handler = async (argv) => {
|
|
|
62
59
|
};
|
|
63
60
|
ws.send(JSON.stringify(payload));
|
|
64
61
|
});
|
|
62
|
+
ws.on('error', (error) => {
|
|
63
|
+
if ('code' in error && error.code === 'ECONNRESET') {
|
|
64
|
+
console.error(`Failed to connect to worker at ${workerUrl}: ${error.message}!\n` +
|
|
65
|
+
'This is unexpected, we apologize for the inconvenience!\n' +
|
|
66
|
+
'Please send us a message and let us know at: support@codeless.qa\n\n' +
|
|
67
|
+
'Thank you! 🙏');
|
|
68
|
+
process.exit(1);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
console.error(error);
|
|
72
|
+
});
|
|
65
73
|
const success = await new Promise((resolve, reject) => {
|
|
66
74
|
const reporterProcess = spawn('node', [require.resolve('tap-mocha-reporter'), reporter], {
|
|
67
75
|
stdio: ['pipe', 'inherit', 'inherit']
|
|
68
76
|
});
|
|
69
77
|
ws.on('message', function message(data) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
try {
|
|
79
|
+
const msg = JSON.parse(data.toString());
|
|
80
|
+
if ('error' in msg && msg.error) {
|
|
81
|
+
return reject(new Error(msg.error));
|
|
82
|
+
}
|
|
83
|
+
if (msg.type === 3) {
|
|
84
|
+
return reporterProcess.stdin.write(msg.value.log);
|
|
85
|
+
}
|
|
86
|
+
if (msg.type === 2) {
|
|
87
|
+
return resolve(msg.value.success);
|
|
88
|
+
}
|
|
89
|
+
if (msg.type === 4) {
|
|
90
|
+
return reject(new Error(msg.value.error));
|
|
91
|
+
}
|
|
76
92
|
}
|
|
77
|
-
|
|
78
|
-
|
|
93
|
+
catch (err) {
|
|
94
|
+
const error = err instanceof Error ? err : new Error('Unknown error');
|
|
95
|
+
return reject(new Error(`Uups! Something went wrong: ${error.message}`));
|
|
79
96
|
}
|
|
80
97
|
});
|
|
81
98
|
});
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const pkg: any;
|
|
2
2
|
export declare const CLI_EPILOGUE: string;
|
|
3
3
|
export declare const PLATFORM_URL: string;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const WORKER_URL: string;
|
|
5
5
|
export declare const TOKEN_PATH: string;
|
|
6
6
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
|
@@ -3,7 +3,10 @@ import { homedir } from 'node:os';
|
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
const require = createRequire(import.meta.url);
|
|
5
5
|
export const pkg = require('../package.json');
|
|
6
|
-
export const CLI_EPILOGUE = `Documentation: https://codeless.qa/docs/cli
|
|
6
|
+
export const CLI_EPILOGUE = `Documentation: https://codeless.qa/docs/cli
|
|
7
|
+
qa (v${pkg.version})
|
|
8
|
+
© 2024 CodelessQA, Inc.
|
|
9
|
+
`;
|
|
7
10
|
export const PLATFORM_URL = 'https://codeless.qa' || 'http://localhost:4000';
|
|
8
|
-
export const
|
|
11
|
+
export const WORKER_URL = 'wss://worker.codeless.qa' || 'localhost:8080';
|
|
9
12
|
export const TOKEN_PATH = path.join(homedir(), '/.codeless-qa');
|