Skip to content

Commit 2d5dd89

Browse files
committed
vizzutest: fix report generation, add t flag
1 parent 832b660 commit 2d5dd89

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

test/integration/vizzutest.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ try {
4040
#url;
4141
#refurl;
4242

43-
#osKey = 'ubuntu_focal';
44-
4543

4644
constructor(testCasesPath) {
4745
if(path.isAbsolute(testCasesPath)) {
@@ -170,7 +168,7 @@ try {
170168
for (let i = 0; i < this.#testCasesRun.length; i++) {
171169
await this.#runTestCase(i);
172170
}
173-
if (argv.reportLevel != 'DISABLED') {
171+
if (argv.reportLevel != 'DISABLED' && argv.t != 'DISABLED') {
174172
this.#createJson(__dirname + '/test_report/', this.#testCasesRun);
175173
}
176174
}
@@ -182,6 +180,7 @@ try {
182180
}
183181

184182
#startTestSuite() {
183+
fs.rmSync(__dirname + '/test_report/' + 'test_cases.json', { force: true });
185184
this.#workspace = new Workspace(this.#workspacePath);
186185
this.#workspace.openWorkspace();
187186
console.log('[ HOSTING ]' + ' ' + '[ ' + 'http://127.0.0.1:' + String(this.#workspace.getWorkspacePort()) + ' ]');
@@ -380,6 +379,7 @@ try {
380379
}
381380
}
382381
let hashes = this.#getTestCaseRefHash(testCase);
382+
this.#testCasesData[testCase]['refs'] = [ testCaseData.hash.substring(0,7) ];
383383
if (hashes === undefined) {
384384
return { testCaseResult: 'WARNING', testCaseReultDescription: 'ref hash does not exist' };
385385
} else {
@@ -427,14 +427,17 @@ try {
427427
fs.mkdirSync(testSuiteResultPath, { recursive: true });
428428
let testCasesData = {};
429429
testCases.forEach(testCase => {
430+
if (argv.t == 'FAILED' && !this.#testSuiteResults.FAILED.includes(testCase)) return;
430431
testCasesData[testCase] = this.#testCasesData[testCase];
431432
});
432-
testCasesData = JSON.stringify(testCasesData, null, 4);
433-
fs.writeFile(testSuiteResultPath + 'test_cases.json', testCasesData, (err) => {
434-
if (err) {
435-
throw err;
436-
}
437-
});
433+
if (Object.keys(testCasesData).length !== 0) {
434+
testCasesData = JSON.stringify(testCasesData, null, 4);
435+
fs.writeFile(testSuiteResultPath + 'test_cases.json', testCasesData, (err) => {
436+
if (err) {
437+
throw err;
438+
}
439+
});
440+
}
438441
}
439442
}
440443

@@ -464,9 +467,12 @@ try {
464467
.alias('r', 'reportLevel')
465468
.choices('r', ['INFO', 'WARN', 'ERROR', 'DISABLED'])
466469
.default('r', 'INFO')
467-
.describe('r', 'Set report level')
470+
.describe('r', 'Set report detail level')
471+
.choices('t', ['ALL', 'FAILED', 'DISABLED'])
472+
.default('t', 'FAILED')
473+
.describe('t', 'Set test_report/test_cases.json detail level')
468474
.alias('u', 'vizzuUrl')
469-
.describe('u', 'Change vizzu.min.js url')
475+
.describe('u', 'Change vizzu.js url')
470476
.nargs('u', 1)
471477
.default('u', '/example/lib')
472478
.argv;

0 commit comments

Comments
 (0)