fix(core): update
This commit is contained in:
parent
e999abbba6
commit
940133493c
7736
package-lock.json
generated
7736
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
11
package.json
11
package.json
@ -11,12 +11,11 @@
|
|||||||
"tstest": "./cli.js"
|
"tstest": "./cli.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npm run prepareTest && npm run tstest && npm run cleanUp)",
|
"test": "(npm run cleanUp && npm run prepareTest && npm run tstest && npm run cleanUp)",
|
||||||
"prepareTest": "git clone https://gitlab.com/sandboxzone/sandbox-npmts.git .nogit/sandbox-npmts && cd .nogit/sandbox-npmts && npm install",
|
"prepareTest": "git clone https://gitlab.com/sandboxzone/sandbox-npmts.git .nogit/sandbox-npmts && cd .nogit/sandbox-npmts && npm install",
|
||||||
"tstest": "cd .nogit/sandbox-npmts && node ../../cli.ts.js test/",
|
"tstest": "cd .nogit/sandbox-npmts && node ../../cli.ts.js test/ --web",
|
||||||
"cleanUp": "rm -rf .nogit/sandbox-npmts",
|
"cleanUp": "rm -rf .nogit/sandbox-npmts",
|
||||||
"format": "(gitzone format)",
|
"build": "(tsbuild --web)"
|
||||||
"build": "(tsbuild)"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.17",
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
@ -25,10 +24,12 @@
|
|||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@gitzone/tsbundle": "^1.0.69",
|
"@gitzone/tsbundle": "^1.0.72",
|
||||||
"@gitzone/tsrun": "^1.2.12",
|
"@gitzone/tsrun": "^1.2.12",
|
||||||
"@pushrocks/consolecolor": "^2.0.1",
|
"@pushrocks/consolecolor": "^2.0.1",
|
||||||
"@pushrocks/smartbrowser": "^1.0.17",
|
"@pushrocks/smartbrowser": "^1.0.17",
|
||||||
|
"@pushrocks/smartdelay": "^2.0.9",
|
||||||
|
"@pushrocks/smartexpress": "^3.0.73",
|
||||||
"@pushrocks/smartfile": "^7.0.6",
|
"@pushrocks/smartfile": "^7.0.6",
|
||||||
"@pushrocks/smartlog": "^2.0.19",
|
"@pushrocks/smartlog": "^2.0.19",
|
||||||
"@pushrocks/smartpromise": "^3.0.6",
|
"@pushrocks/smartpromise": "^3.0.6",
|
||||||
|
@ -105,14 +105,14 @@ export class TapParser {
|
|||||||
/**
|
/**
|
||||||
* returns all tests that are not completed
|
* returns all tests that are not completed
|
||||||
*/
|
*/
|
||||||
getUncompletedTests() {
|
public getUncompletedTests() {
|
||||||
// TODO:
|
// TODO:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns all tests that threw an error
|
* returns all tests that threw an error
|
||||||
*/
|
*/
|
||||||
getErrorTests() {
|
public getErrorTests() {
|
||||||
return this.testStore.filter(tapTestArg => {
|
return this.testStore.filter(tapTestArg => {
|
||||||
return !tapTestArg.testOk;
|
return !tapTestArg.testOk;
|
||||||
});
|
});
|
||||||
@ -123,7 +123,7 @@ export class TapParser {
|
|||||||
*/
|
*/
|
||||||
getTestOverviewAsString() {
|
getTestOverviewAsString() {
|
||||||
let overviewString = '';
|
let overviewString = '';
|
||||||
for (let test of this.testStore) {
|
for (const test of this.testStore) {
|
||||||
if (overviewString !== '') {
|
if (overviewString !== '') {
|
||||||
overviewString += ' | ';
|
overviewString += ' | ';
|
||||||
}
|
}
|
||||||
@ -181,4 +181,8 @@ export class TapParser {
|
|||||||
});
|
});
|
||||||
await done.promise;
|
await done.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public handleTapLog(tapLog: string) {
|
||||||
|
this._processLog(tapLog);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,19 @@ import { coloredString as cs } from '@pushrocks/consolecolor';
|
|||||||
import { TestDirectory } from './tstest.classes.testdirectory';
|
import { TestDirectory } from './tstest.classes.testdirectory';
|
||||||
import { TapCombinator } from './tstest.classes.tap.combinator';
|
import { TapCombinator } from './tstest.classes.tap.combinator';
|
||||||
import { TapParser } from './tstest.classes.tap.parser';
|
import { TapParser } from './tstest.classes.tap.parser';
|
||||||
|
import { threeEighths } from 'figures';
|
||||||
|
|
||||||
export class TsTest {
|
export class TsTest {
|
||||||
testDir: TestDirectory;
|
public testDir: TestDirectory;
|
||||||
|
|
||||||
|
public smartshellInstance = new plugins.smartshell.Smartshell({
|
||||||
|
executor: 'bash',
|
||||||
|
pathDirectories: [paths.binDirectory],
|
||||||
|
sourceFilePaths: [],
|
||||||
|
});
|
||||||
|
public smartbrowserInstance = new plugins.smartbrowser.SmartBrowser();
|
||||||
|
|
||||||
|
public tsbundleInstance = new plugins.tsbundle.TsBundle();
|
||||||
|
|
||||||
constructor(cwdArg: string, relativePathToTestDirectory: string) {
|
constructor(cwdArg: string, relativePathToTestDirectory: string) {
|
||||||
this.testDir = new TestDirectory(cwdArg, relativePathToTestDirectory);
|
this.testDir = new TestDirectory(cwdArg, relativePathToTestDirectory);
|
||||||
@ -25,31 +35,98 @@ export class TsTest {
|
|||||||
}
|
}
|
||||||
console.log('-'.repeat(48));
|
console.log('-'.repeat(48));
|
||||||
console.log(''); // force new line
|
console.log(''); // force new line
|
||||||
const smartshellInstance = new plugins.smartshell.Smartshell({
|
|
||||||
executor: 'bash',
|
|
||||||
pathDirectories: [paths.binDirectory],
|
|
||||||
sourceFilePaths: []
|
|
||||||
});
|
|
||||||
const tapCombinator = new TapCombinator(); // lets create the TapCombinator
|
const tapCombinator = new TapCombinator(); // lets create the TapCombinator
|
||||||
for (const fileName of fileNamesToRun) {
|
for (const fileNameArg of fileNamesToRun) {
|
||||||
console.log(`${cs('=> ', 'blue')} Running ${cs(fileName, 'orange')}`);
|
let tapParser: TapParser;
|
||||||
console.log(cs(`=`.repeat(16), 'cyan'));
|
switch(true) {
|
||||||
const tapParser = new TapParser(fileName);
|
case fileNameArg.endsWith('.browser.ts'):
|
||||||
|
tapParser = await this.runInChrome(fileNameArg);
|
||||||
// tsrun options
|
break;
|
||||||
let tsrunOptions = '';
|
default:
|
||||||
if (process.argv.includes('--web')) {
|
tapParser = await this.runInNode(fileNameArg);
|
||||||
tsrunOptions += ' --web';
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const execResultStreaming = await smartshellInstance.execStreamingSilent(
|
|
||||||
`tsrun ${fileName}${tsrunOptions}`
|
|
||||||
);
|
|
||||||
await tapParser.handleTapProcess(execResultStreaming.childProcess);
|
|
||||||
console.log(cs(`^`.repeat(16), 'cyan'));
|
|
||||||
console.log(''); // force new line
|
|
||||||
tapCombinator.addTapParser(tapParser);
|
tapCombinator.addTapParser(tapParser);
|
||||||
}
|
}
|
||||||
tapCombinator.evaluate();
|
tapCombinator.evaluate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async runInNode(fileNameArg: string): Promise<TapParser> {
|
||||||
|
console.log(`${cs('=> ', 'blue')} Running ${cs(fileNameArg, 'orange')} in node.js runtime.`);
|
||||||
|
console.log(cs(`=`.repeat(16), 'cyan'));
|
||||||
|
const tapParser = new TapParser(fileNameArg);
|
||||||
|
|
||||||
|
// tsrun options
|
||||||
|
let tsrunOptions = '';
|
||||||
|
if (process.argv.includes('--web')) {
|
||||||
|
tsrunOptions += ' --web';
|
||||||
|
}
|
||||||
|
|
||||||
|
const execResultStreaming = await this.smartshellInstance.execStreamingSilent(
|
||||||
|
`tsrun ${fileNameArg}${tsrunOptions}`
|
||||||
|
);
|
||||||
|
await tapParser.handleTapProcess(execResultStreaming.childProcess);
|
||||||
|
console.log(cs(`^`.repeat(16), 'cyan'));
|
||||||
|
console.log(''); // force new line
|
||||||
|
return tapParser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async runInChrome(fileNameArg: string): Promise<TapParser> {
|
||||||
|
console.log(`${cs('=> ', 'blue')} Running ${cs(fileNameArg, 'orange')} in chromium runtime.`);
|
||||||
|
console.log(cs(`=`.repeat(16), 'cyan'));
|
||||||
|
|
||||||
|
// lets get all our paths sorted
|
||||||
|
const tsbundleCacheDirPath = plugins.path.join(paths.cwd, './.nogit/tstest_cache');
|
||||||
|
const bundleFileName = fileNameArg.replace('/', '__') + '.js';
|
||||||
|
const bundleFilePath = plugins.path.join(tsbundleCacheDirPath, bundleFileName);
|
||||||
|
|
||||||
|
// lets bundle the test
|
||||||
|
await plugins.smartfile.fs.ensureDir(tsbundleCacheDirPath);
|
||||||
|
await this.tsbundleInstance.buildTest(fileNameArg, bundleFilePath, 'parcel');
|
||||||
|
|
||||||
|
// lets create a server
|
||||||
|
const server = new plugins.smartexpress.Server({
|
||||||
|
cors: true,
|
||||||
|
port: 3007
|
||||||
|
});
|
||||||
|
server.addRoute('/test', new plugins.smartexpress.Handler('GET', async (req, res) => {
|
||||||
|
res.type('.html');
|
||||||
|
res.write(`
|
||||||
|
<html>
|
||||||
|
<head></head>
|
||||||
|
<body></body>
|
||||||
|
</html>
|
||||||
|
`);
|
||||||
|
res.end();
|
||||||
|
}));
|
||||||
|
server.addRoute('*', new plugins.smartexpress.HandlerStatic(tsbundleCacheDirPath));
|
||||||
|
await server.start();
|
||||||
|
|
||||||
|
// lets do the browser bit
|
||||||
|
await this.smartbrowserInstance.start();
|
||||||
|
const evaluation = await this.smartbrowserInstance.evaluateOnPage('http://localhost:3007/test', async () => {
|
||||||
|
const logStore = 'hello';
|
||||||
|
const log = console.log.bind(console);
|
||||||
|
console.log = (...args) => {
|
||||||
|
log('My Console!!!');
|
||||||
|
log(...args);
|
||||||
|
};
|
||||||
|
const script = document.createElement('script');
|
||||||
|
script.src = '/test__test.browser.ts.js';
|
||||||
|
document.head.appendChild(script);
|
||||||
|
return logStore;
|
||||||
|
});
|
||||||
|
await plugins.smartdelay.delayFor(1000);
|
||||||
|
await this.smartbrowserInstance.stop();
|
||||||
|
console.log(`${cs('=> ', 'blue')} Stopped ${cs(fileNameArg, 'orange')} chromium instance.`);
|
||||||
|
await server.stop();
|
||||||
|
console.log(`${cs('=> ', 'blue')} Stopped ${cs(fileNameArg, 'orange')} server.`);
|
||||||
|
// lets create the tap parser
|
||||||
|
const tapParser = new TapParser(fileNameArg);
|
||||||
|
tapParser.handleTapLog(evaluation);
|
||||||
|
return tapParser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async runInDeno() {}
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,21 @@ export { path };
|
|||||||
// @pushrocks scope
|
// @pushrocks scope
|
||||||
import * as consolecolor from '@pushrocks/consolecolor';
|
import * as consolecolor from '@pushrocks/consolecolor';
|
||||||
import * as smartbrowser from '@pushrocks/smartbrowser';
|
import * as smartbrowser from '@pushrocks/smartbrowser';
|
||||||
|
import * as smartexpress from '@pushrocks/smartexpress';
|
||||||
|
import * as smartdelay from '@pushrocks/smartdelay';
|
||||||
import * as smartfile from '@pushrocks/smartfile';
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
import * as smartlog from '@pushrocks/smartlog';
|
import * as smartlog from '@pushrocks/smartlog';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
import * as smartshell from '@pushrocks/smartshell';
|
import * as smartshell from '@pushrocks/smartshell';
|
||||||
|
|
||||||
export { consolecolor, smartfile, smartlog, smartpromise, smartshell };
|
export { consolecolor, smartbrowser, smartexpress, smartdelay, smartfile, smartlog, smartpromise, smartshell };
|
||||||
|
|
||||||
|
// @gitzone scope
|
||||||
|
import * as tsbundle from '@gitzone/tsbundle';
|
||||||
|
|
||||||
|
export {
|
||||||
|
tsbundle
|
||||||
|
};
|
||||||
|
|
||||||
// sindresorhus
|
// sindresorhus
|
||||||
import * as figures from 'figures';
|
import * as figures from 'figures';
|
||||||
|
Loading…
Reference in New Issue
Block a user