Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
6bee853cd2 | |||
4aa731b531 | |||
a849f36a1b | |||
30284b770c |
29
package-lock.json
generated
29
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@gitzone/tstest",
|
||||
"version": "1.0.35",
|
||||
"version": "1.0.37",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@ -1567,16 +1567,31 @@
|
||||
}
|
||||
},
|
||||
"@pushrocks/tapbundle": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2ftapbundle/-/tapbundle-3.2.1.tgz",
|
||||
"integrity": "sha512-D3o205SE+Viu8sukm+6CvGkXEwOiQiEEcga9eWyvjWS4vDx6FWwrO0pNZkQq6GqsKQ9xRpCmBtI7F3KsJR0+PA==",
|
||||
"version": "3.2.7",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2ftapbundle/-/tapbundle-3.2.7.tgz",
|
||||
"integrity": "sha512-RBRjuJs3v/biKypc9rSecApn7IXRdmr/jbVH86+2mDxyzUQ8IcMhaKhUrIjKoNyvxvMAMS2j+OxPyiOCnK6RAw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/early": "^3.0.3",
|
||||
"@pushrocks/smartdelay": "^2.0.3",
|
||||
"@pushrocks/smartfile": "^7.0.9",
|
||||
"@pushrocks/smartdelay": "^2.0.9",
|
||||
"@pushrocks/smartenv": "^4.0.10",
|
||||
"@pushrocks/smartpromise": "^3.0.2",
|
||||
"@pushrocks/smarttime": "^3.0.19",
|
||||
"smartchai": "^2.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smarttime": {
|
||||
"version": "3.0.19",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmarttime/-/smarttime-3.0.19.tgz",
|
||||
"integrity": "sha512-1iSkNJcF632Mikcd/EvcBPC1T5tLRZqTHjVkuZlXpaNY11eZIzYVMOn5/ZDfLp2GuEi6hhIbEx9zwsdoYqz5cA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/smartdelay": "^2.0.9",
|
||||
"@pushrocks/smartpromise": "^3.0.2",
|
||||
"croner": "^1.1.23",
|
||||
"dayjs": "^1.8.27",
|
||||
"is-nan": "^1.3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@pushrocks/webrequest": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@gitzone/tstest",
|
||||
"version": "1.0.35",
|
||||
"version": "1.0.37",
|
||||
"private": false,
|
||||
"description": "a test utility to run tests that match test/**/*.ts",
|
||||
"main": "dist_ts/index.js",
|
||||
@ -19,7 +19,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.17",
|
||||
"@pushrocks/tapbundle": "^3.0.13",
|
||||
"@pushrocks/tapbundle": "^3.2.7",
|
||||
"tslint": "^6.1.2",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
},
|
||||
|
@ -113,7 +113,7 @@ export class TapParser {
|
||||
* returns all tests that threw an error
|
||||
*/
|
||||
public getErrorTests() {
|
||||
return this.testStore.filter(tapTestArg => {
|
||||
return this.testStore.filter((tapTestArg) => {
|
||||
return !tapTestArg.testOk;
|
||||
});
|
||||
}
|
||||
@ -140,49 +140,54 @@ export class TapParser {
|
||||
* handles a tap process
|
||||
* @param childProcessArg
|
||||
*/
|
||||
async handleTapProcess(childProcessArg: ChildProcess) {
|
||||
public async handleTapProcess(childProcessArg: ChildProcess) {
|
||||
const done = plugins.smartpromise.defer();
|
||||
childProcessArg.stdout.on('data', data => {
|
||||
childProcessArg.stdout.on('data', (data) => {
|
||||
this._processLog(data);
|
||||
});
|
||||
childProcessArg.stderr.on('data', data => {
|
||||
childProcessArg.stderr.on('data', (data) => {
|
||||
this._processLog(data);
|
||||
});
|
||||
childProcessArg.on('exit', () => {
|
||||
this.receivedTests = this.testStore.length;
|
||||
|
||||
// check wether all tests ran
|
||||
if (this.expectedTests === this.receivedTests) {
|
||||
console.log(
|
||||
`${logPrefixes.TapPrefix} ${cs(
|
||||
`${this.receivedTests} out of ${this.expectedTests} Tests completed!`,
|
||||
'green'
|
||||
)}`
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
`${logPrefixes.TapErrorPrefix} ${cs(
|
||||
`Only ${this.receivedTests} out of ${this.expectedTests} completed!`,
|
||||
'red'
|
||||
)}`
|
||||
);
|
||||
}
|
||||
if (this.getErrorTests().length === 0) {
|
||||
console.log(`${logPrefixes.TapPrefix} ${cs(`All tests are successfull!!!`, 'green')}`);
|
||||
} else {
|
||||
console.log(
|
||||
`${logPrefixes.TapPrefix} ${cs(
|
||||
`${this.getErrorTests().length} tests threw an error!!!`,
|
||||
'red'
|
||||
)}`
|
||||
);
|
||||
}
|
||||
childProcessArg.on('exit', async () => {
|
||||
await this._evaluateResult();
|
||||
done.resolve();
|
||||
});
|
||||
await done.promise;
|
||||
}
|
||||
|
||||
public handleTapLog(tapLog: string) {
|
||||
public async handleTapLog(tapLog: string) {
|
||||
this._processLog(tapLog);
|
||||
await this._evaluateResult();
|
||||
}
|
||||
|
||||
private async _evaluateResult() {
|
||||
this.receivedTests = this.testStore.length;
|
||||
|
||||
// check wether all tests ran
|
||||
if (this.expectedTests === this.receivedTests) {
|
||||
console.log(
|
||||
`${logPrefixes.TapPrefix} ${cs(
|
||||
`${this.receivedTests} out of ${this.expectedTests} Tests completed!`,
|
||||
'green'
|
||||
)}`
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
`${logPrefixes.TapErrorPrefix} ${cs(
|
||||
`Only ${this.receivedTests} out of ${this.expectedTests} completed!`,
|
||||
'red'
|
||||
)}`
|
||||
);
|
||||
}
|
||||
if (this.getErrorTests().length === 0) {
|
||||
console.log(`${logPrefixes.TapPrefix} ${cs(`All tests are successfull!!!`, 'green')}`);
|
||||
} else {
|
||||
console.log(
|
||||
`${logPrefixes.TapPrefix} ${cs(
|
||||
`${this.getErrorTests().length} tests threw an error!!!`,
|
||||
'red'
|
||||
)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,8 @@ export class TsTest {
|
||||
break;
|
||||
}
|
||||
tapCombinator.addTapParser(tapParser);
|
||||
console.log(cs(`^`.repeat(16), 'cyan'));
|
||||
console.log(''); // force new line
|
||||
}
|
||||
tapCombinator.evaluate();
|
||||
}
|
||||
@ -67,8 +69,6 @@ export class TsTest {
|
||||
`tsrun ${fileNameArg}${tsrunOptions}`
|
||||
);
|
||||
await tapParser.handleTapProcess(execResultStreaming.childProcess);
|
||||
console.log(cs(`^`.repeat(16), 'cyan'));
|
||||
console.log(''); // force new line
|
||||
return tapParser;
|
||||
}
|
||||
|
||||
@ -115,42 +115,6 @@ export class TsTest {
|
||||
const evaluation = await this.smartbrowserInstance.evaluateOnPage(
|
||||
`http://localhost:3007/test?bundleName=${bundleFileName}`,
|
||||
async () => {
|
||||
let logStore = 'Starting log capture\n';
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
class Deferred<T> {
|
||||
public promise: Promise<T>;
|
||||
public resolve;
|
||||
public reject;
|
||||
public status;
|
||||
|
||||
public startedAt: number;
|
||||
public stoppedAt: number;
|
||||
public get duration(): number {
|
||||
if (this.stoppedAt) {
|
||||
return this.stoppedAt - this.startedAt;
|
||||
} else {
|
||||
return Date.now() - this.startedAt;
|
||||
}
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.promise = new Promise<T>((resolve, reject) => {
|
||||
this.resolve = (valueArg: T | PromiseLike<T>) => {
|
||||
this.status = 'fulfilled';
|
||||
this.stoppedAt = Date.now();
|
||||
resolve(valueArg);
|
||||
};
|
||||
this.reject = (reason: any) => {
|
||||
this.status = 'rejected';
|
||||
this.stoppedAt = Date.now();
|
||||
reject(reason);
|
||||
};
|
||||
this.startedAt = Date.now();
|
||||
this.status = 'pending';
|
||||
});
|
||||
}
|
||||
}
|
||||
const done = new Deferred();
|
||||
const convertToText = (obj) => {
|
||||
// create an array that will later be joined into a string.
|
||||
const stringArray = [];
|
||||
@ -181,6 +145,9 @@ export class TsTest {
|
||||
|
||||
return stringArray.join('');
|
||||
};
|
||||
|
||||
let logStore = 'Starting log capture\n';
|
||||
// tslint:disable-next-line: max-classes-per-file
|
||||
const log = console.log.bind(console);
|
||||
console.log = (...args) => {
|
||||
args = args.map((argument) => {
|
||||
@ -204,15 +171,15 @@ export class TsTest {
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
setTimeout(() => {
|
||||
console.log(globalThis.testdom);
|
||||
done.resolve();
|
||||
}, 5000);
|
||||
await done.promise;
|
||||
|
||||
if (globalThis.tapbundleDeferred && globalThis.tapbundleDeferred.promise) {
|
||||
await globalThis.tapbundleDeferred.promise;
|
||||
} else {
|
||||
console.log('Error: Could not find tapbundle Deferred');
|
||||
}
|
||||
return logStore;
|
||||
}
|
||||
);
|
||||
await plugins.smartdelay.delayFor(1000);
|
||||
await this.smartbrowserInstance.stop();
|
||||
console.log(`${cs('=> ', 'blue')} Stopped ${cs(fileNameArg, 'orange')} chromium instance.`);
|
||||
await server.stop();
|
||||
|
Reference in New Issue
Block a user