Compare commits
56 Commits
Author | SHA1 | Date | |
---|---|---|---|
bd6713eee8 | |||
440b41611b | |||
78a40de700 | |||
e0eb00d755 | |||
dbbcbf4ea2 | |||
8c13b9db89 | |||
f813a79124 | |||
766138aa25 | |||
72880b4a2d | |||
bd5731c439 | |||
0caebb7448 | |||
ed896b7f1c | |||
69ec5a98ab | |||
3b93886147 | |||
5949988293 | |||
04f7be07a3 | |||
d331f90d24 | |||
224400dcb5 | |||
7601ca599a | |||
994a1bc98d | |||
ca51c9e15b | |||
4c4f08152b | |||
39bd80106a | |||
d6b94b534b | |||
d19d3fc51e | |||
f7f1bf25f6 | |||
42fd414609 | |||
8f16f46c37 | |||
f8afb2c7f6 | |||
a3d1fbb2da | |||
0da1a1bc5b | |||
1ede0b476a | |||
1d251689bb | |||
8f1492dfbd | |||
003dc473ea | |||
e6baed5470 | |||
d9a27adb4a | |||
eabb75a9a8 | |||
deb63c1af5 | |||
7ee3969798 | |||
61eea77805 | |||
3d9685ac6f | |||
4ec56c3f0b | |||
ab33720aba | |||
5e42565567 | |||
88b7581eeb | |||
0ea621cb99 | |||
984d551bd6 | |||
4066d9b0e8 | |||
f24ff2f79e | |||
9d37fcf734 | |||
f7524179d7 | |||
19d6b52ddb | |||
cf69e5436c | |||
6bee853cd2 | |||
4aa731b531 |
@ -12,6 +12,9 @@ stages:
|
|||||||
- release
|
- release
|
||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- npm install -g @shipzone/npmci
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
# ====================
|
# ====================
|
||||||
@ -19,23 +22,36 @@ mirror:
|
|||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
audit:
|
auditProductionDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci command npm install --production --ignore-scripts
|
||||||
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command npm audit --audit-level=high --only=prod --production
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
|
auditDevDependencies:
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
- npmci command npm audit --audit-level=high
|
- npmci command npm audit --audit-level=high --only=dev
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
allow_failure: true
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
@ -50,9 +66,7 @@ testStable:
|
|||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- priv
|
|
||||||
|
|
||||||
testBuild:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
@ -63,9 +77,7 @@ testBuild:
|
|||||||
- npmci command npm run build
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
@ -85,6 +97,8 @@ release:
|
|||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g tslint typescript
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
|
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -2,28 +2,10 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "current file",
|
"command": "npm test",
|
||||||
"type": "node",
|
"name": "Run npm test",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"args": [
|
"type": "node-terminal"
|
||||||
"${relativeFile}"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test.ts",
|
|
||||||
"type": "node",
|
|
||||||
"request": "launch",
|
|
||||||
"args": [
|
|
||||||
"test/test.ts"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -15,7 +15,7 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"projectType": {
|
"projectType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["website", "element", "service", "npm"]
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "gitzone",
|
"gitscope": "gitzone",
|
||||||
"gitrepo": "tstest",
|
"gitrepo": "tstest",
|
||||||
"shortDescription": "a test utility to run tests that match test/**/*.ts",
|
"description": "a test utility to run tests that match test/**/*.ts",
|
||||||
"npmPackagename": "@gitzone/tstest",
|
"npmPackagename": "@gitzone/tstest",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
|
22422
package-lock.json
generated
22422
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
29
package.json
29
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tstest",
|
"name": "@gitzone/tstest",
|
||||||
"version": "1.0.36",
|
"version": "1.0.64",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "a test utility to run tests that match test/**/*.ts",
|
"description": "a test utility to run tests that match test/**/*.ts",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@ -18,22 +18,22 @@
|
|||||||
"build": "(tsbuild --web)"
|
"build": "(tsbuild --web)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.17",
|
"@gitzone/tsbuild": "^2.1.29",
|
||||||
"@pushrocks/tapbundle": "^3.0.13",
|
"tslint": "^6.1.3",
|
||||||
"tslint": "^6.1.2",
|
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@gitzone/tsbundle": "^1.0.72",
|
"@gitzone/tsbundle": "^1.0.89",
|
||||||
"@gitzone/tsrun": "^1.2.12",
|
"@gitzone/tsrun": "^1.2.18",
|
||||||
"@pushrocks/consolecolor": "^2.0.1",
|
"@pushrocks/consolecolor": "^2.0.1",
|
||||||
"@pushrocks/smartbrowser": "^1.0.17",
|
"@pushrocks/smartbrowser": "^1.0.22",
|
||||||
"@pushrocks/smartdelay": "^2.0.9",
|
"@pushrocks/smartdelay": "^2.0.13",
|
||||||
"@pushrocks/smartexpress": "^3.0.73",
|
"@pushrocks/smartexpress": "^3.0.108",
|
||||||
"@pushrocks/smartfile": "^7.0.6",
|
"@pushrocks/smartfile": "^9.0.5",
|
||||||
"@pushrocks/smartlog": "^2.0.19",
|
"@pushrocks/smartlog": "^2.0.44",
|
||||||
"@pushrocks/smartpromise": "^3.0.6",
|
"@pushrocks/smartpromise": "^3.1.6",
|
||||||
"@pushrocks/smartshell": "^2.0.25",
|
"@pushrocks/smartshell": "^2.0.30",
|
||||||
|
"@pushrocks/tapbundle": "^4.0.3",
|
||||||
"@types/figures": "^3.0.1",
|
"@types/figures": "^3.0.1",
|
||||||
"figures": "^3.0.0"
|
"figures": "^3.0.0"
|
||||||
},
|
},
|
||||||
@ -48,5 +48,8 @@
|
|||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
25
readme.md
25
readme.md
@ -19,12 +19,35 @@ TypeScript Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
Code Style | [](https://lossless.cloud)
|
Code Style | [](https://lossless.cloud)
|
||||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
## cli usage
|
||||||
|
|
||||||
|
lets assume we have a directory called test/ where all our tests arae defined. Simply type
|
||||||
|
|
||||||
|
```
|
||||||
|
tstest test/
|
||||||
|
```
|
||||||
|
|
||||||
|
to run all tests.
|
||||||
|
|
||||||
|
## Syntax
|
||||||
|
|
||||||
|
tstest supports tap syntax. In other words your testfiles are run in a subprocess, and the console output contains trigger messages for tstest to determine test status. Inside your testfile you should use `@pushrocks/tapbundle` for the best results.
|
||||||
|
|
||||||
|
## Environments
|
||||||
|
|
||||||
|
tstest supports different environments:
|
||||||
|
|
||||||
|
- a testfile called `test-something.node.ts` will be run in node
|
||||||
|
- a testfile called `test-something.chrome.ts` will be run in chrome environment (bundled through parcel and run through puppeteer)
|
||||||
|
- a testfile called `test-something.both.ts` will be run in node an chrome, which is good for isomorphic packages.
|
||||||
|
|
||||||
|
> note: there is alpha support for the deno environment by naming a file test-something.deno.ts
|
||||||
|
|
||||||
## Contribution
|
## Contribution
|
||||||
|
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
import { TsTest } from './tstest.classes.tstest';
|
import { TsTest } from './tstest.classes.tstest';
|
||||||
|
|
||||||
export const runCli = async () => {
|
export const runCli = async () => {
|
||||||
|
if (!process.argv[2]) {
|
||||||
|
console.error('You must specify a test directory as argument. Please try again.');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
const tsTestInstance = new TsTest(process.cwd(), process.argv[2]);
|
const tsTestInstance = new TsTest(process.cwd(), process.argv[2]);
|
||||||
await tsTestInstance.run();
|
await tsTestInstance.run();
|
||||||
};
|
};
|
||||||
|
@ -20,7 +20,24 @@ export class TapCombinator {
|
|||||||
|
|
||||||
let failGlobal = false; // determine wether tstest should fail
|
let failGlobal = false; // determine wether tstest should fail
|
||||||
for (const tapParser of this.tapParserStore) {
|
for (const tapParser of this.tapParserStore) {
|
||||||
if (tapParser.getErrorTests().length === 0) {
|
if (!tapParser.expectedTests) {
|
||||||
|
failGlobal = true;
|
||||||
|
let overviewString =
|
||||||
|
logPrefixes.TsTestPrefix +
|
||||||
|
cs(` ${tapParser.fileName} ${plugins.figures.cross}`, 'red') +
|
||||||
|
` ${plugins.figures.pointer} ` +
|
||||||
|
`does not specify tests!`;
|
||||||
|
console.log(overviewString);
|
||||||
|
} else if (tapParser.expectedTests !== tapParser.receivedTests) {
|
||||||
|
failGlobal = true;
|
||||||
|
let overviewString =
|
||||||
|
logPrefixes.TsTestPrefix +
|
||||||
|
cs(` ${tapParser.fileName} ${plugins.figures.cross}`, 'red') +
|
||||||
|
` ${plugins.figures.pointer} ` +
|
||||||
|
tapParser.getTestOverviewAsString() +
|
||||||
|
`did not execute all specified tests!`;
|
||||||
|
console.log(overviewString);
|
||||||
|
} else if (tapParser.getErrorTests().length === 0) {
|
||||||
let overviewString =
|
let overviewString =
|
||||||
logPrefixes.TsTestPrefix +
|
logPrefixes.TsTestPrefix +
|
||||||
cs(` ${tapParser.fileName} ${plugins.figures.tick}`, 'green') +
|
cs(` ${tapParser.fileName} ${plugins.figures.tick}`, 'green') +
|
||||||
@ -28,13 +45,13 @@ export class TapCombinator {
|
|||||||
tapParser.getTestOverviewAsString();
|
tapParser.getTestOverviewAsString();
|
||||||
console.log(overviewString);
|
console.log(overviewString);
|
||||||
} else {
|
} else {
|
||||||
|
failGlobal = true;
|
||||||
let overviewString =
|
let overviewString =
|
||||||
logPrefixes.TsTestPrefix +
|
logPrefixes.TsTestPrefix +
|
||||||
cs(` ${tapParser.fileName} ${plugins.figures.cross}`, 'red') +
|
cs(` ${tapParser.fileName} ${plugins.figures.cross}`, 'red') +
|
||||||
` ${plugins.figures.pointer} ` +
|
` ${plugins.figures.pointer} ` +
|
||||||
tapParser.getTestOverviewAsString();
|
tapParser.getTestOverviewAsString();
|
||||||
console.log(overviewString);
|
console.log(overviewString);
|
||||||
failGlobal = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(cs(plugins.figures.hamburger.repeat(48), 'cyan'));
|
console.log(cs(plugins.figures.hamburger.repeat(48), 'cyan'));
|
||||||
|
@ -179,7 +179,16 @@ export class TapParser {
|
|||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (this.getErrorTests().length === 0) {
|
if (!this.expectedTests) {
|
||||||
|
console.log(cs('Error: No tests were defined. Therefore the testfile failed!', 'red'));
|
||||||
|
} else if (this.expectedTests !== this.receivedTests) {
|
||||||
|
console.log(
|
||||||
|
cs(
|
||||||
|
'Error: The amount of received tests and expectedTests is unequal! Therefore the testfile failed',
|
||||||
|
'red'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else if (this.getErrorTests().length === 0) {
|
||||||
console.log(`${logPrefixes.TapPrefix} ${cs(`All tests are successfull!!!`, 'green')}`);
|
console.log(`${logPrefixes.TapPrefix} ${cs(`All tests are successfull!!!`, 'green')}`);
|
||||||
} else {
|
} else {
|
||||||
console.log(
|
console.log(
|
||||||
|
@ -7,7 +7,6 @@ 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 {
|
||||||
public testDir: TestDirectory;
|
public testDir: TestDirectory;
|
||||||
@ -38,16 +37,34 @@ export class TsTest {
|
|||||||
|
|
||||||
const tapCombinator = new TapCombinator(); // lets create the TapCombinator
|
const tapCombinator = new TapCombinator(); // lets create the TapCombinator
|
||||||
for (const fileNameArg of fileNamesToRun) {
|
for (const fileNameArg of fileNamesToRun) {
|
||||||
let tapParser: TapParser;
|
|
||||||
switch (true) {
|
switch (true) {
|
||||||
|
case process.env.CI && fileNameArg.includes('.nonci.'):
|
||||||
|
console.log('!!!!!!!!!!!');
|
||||||
|
console.log(
|
||||||
|
`not running testfile ${fileNameArg}, sinc we are CI and file name includes '.nonci.' tag`
|
||||||
|
);
|
||||||
|
console.log('!!!!!!!!!!!');
|
||||||
|
break;
|
||||||
case fileNameArg.endsWith('.browser.ts'):
|
case fileNameArg.endsWith('.browser.ts'):
|
||||||
tapParser = await this.runInChrome(fileNameArg);
|
const tapParserBrowser = await this.runInChrome(fileNameArg);
|
||||||
|
tapCombinator.addTapParser(tapParserBrowser);
|
||||||
|
break;
|
||||||
|
case fileNameArg.endsWith('.both.ts'):
|
||||||
|
console.log('>>>>>>> TEST PART 1: chrome');
|
||||||
|
const tapParserBothBrowser = await this.runInChrome(fileNameArg);
|
||||||
|
tapCombinator.addTapParser(tapParserBothBrowser);
|
||||||
|
console.log(cs(`|`.repeat(16), 'cyan'));
|
||||||
|
console.log(''); // force new line
|
||||||
|
console.log('>>>>>>> TEST PART 2: node');
|
||||||
|
const tapParserBothNode = await this.runInNode(fileNameArg);
|
||||||
|
tapCombinator.addTapParser(tapParserBothNode);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
tapParser = await this.runInNode(fileNameArg);
|
const tapParserNode = await this.runInNode(fileNameArg);
|
||||||
|
tapCombinator.addTapParser(tapParserNode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tapCombinator.addTapParser(tapParser);
|
|
||||||
console.log(cs(`^`.repeat(16), 'cyan'));
|
console.log(cs(`^`.repeat(16), 'cyan'));
|
||||||
console.log(''); // force new line
|
console.log(''); // force new line
|
||||||
}
|
}
|
||||||
@ -56,8 +73,8 @@ export class TsTest {
|
|||||||
|
|
||||||
public async runInNode(fileNameArg: string): Promise<TapParser> {
|
public async runInNode(fileNameArg: string): Promise<TapParser> {
|
||||||
console.log(`${cs('=> ', 'blue')} Running ${cs(fileNameArg, 'orange')} in node.js runtime.`);
|
console.log(`${cs('=> ', 'blue')} Running ${cs(fileNameArg, 'orange')} in node.js runtime.`);
|
||||||
console.log(cs(`=`.repeat(16), 'cyan'));
|
console.log(`${cs(`= `.repeat(32), 'cyan')}`);
|
||||||
const tapParser = new TapParser(fileNameArg);
|
const tapParser = new TapParser(fileNameArg + ':node');
|
||||||
|
|
||||||
// tsrun options
|
// tsrun options
|
||||||
let tsrunOptions = '';
|
let tsrunOptions = '';
|
||||||
@ -74,7 +91,7 @@ export class TsTest {
|
|||||||
|
|
||||||
public async runInChrome(fileNameArg: string): Promise<TapParser> {
|
public async runInChrome(fileNameArg: string): Promise<TapParser> {
|
||||||
console.log(`${cs('=> ', 'blue')} Running ${cs(fileNameArg, 'orange')} in chromium runtime.`);
|
console.log(`${cs('=> ', 'blue')} Running ${cs(fileNameArg, 'orange')} in chromium runtime.`);
|
||||||
console.log(cs(`=`.repeat(16), 'cyan'));
|
console.log(`${cs(`= `.repeat(32), 'cyan')}`);
|
||||||
|
|
||||||
// lets get all our paths sorted
|
// lets get all our paths sorted
|
||||||
const tsbundleCacheDirPath = plugins.path.join(paths.cwd, './.nogit/tstest_cache');
|
const tsbundleCacheDirPath = plugins.path.join(paths.cwd, './.nogit/tstest_cache');
|
||||||
@ -83,7 +100,7 @@ export class TsTest {
|
|||||||
|
|
||||||
// lets bundle the test
|
// lets bundle the test
|
||||||
await plugins.smartfile.fs.ensureDir(tsbundleCacheDirPath);
|
await plugins.smartfile.fs.ensureDir(tsbundleCacheDirPath);
|
||||||
await this.tsbundleInstance.buildTest(fileNameArg, bundleFilePath, 'parcel');
|
await this.tsbundleInstance.buildTest(process.cwd(), fileNameArg, bundleFilePath, 'parcel');
|
||||||
|
|
||||||
// lets create a server
|
// lets create a server
|
||||||
const server = new plugins.smartexpress.Server({
|
const server = new plugins.smartexpress.Server({
|
||||||
@ -115,47 +132,13 @@ export class TsTest {
|
|||||||
const evaluation = await this.smartbrowserInstance.evaluateOnPage(
|
const evaluation = await this.smartbrowserInstance.evaluateOnPage(
|
||||||
`http://localhost:3007/test?bundleName=${bundleFileName}`,
|
`http://localhost:3007/test?bundleName=${bundleFileName}`,
|
||||||
async () => {
|
async () => {
|
||||||
let logStore = 'Starting log capture\n';
|
const convertToText = (obj: any): string => {
|
||||||
// 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.
|
// create an array that will later be joined into a string.
|
||||||
const stringArray = [];
|
const stringArray = [];
|
||||||
|
|
||||||
if (typeof obj === 'object' && obj.join === undefined) {
|
if (typeof obj === 'object' && typeof obj.toString === 'function') {
|
||||||
|
stringArray.push(obj.toString());
|
||||||
|
} else if (typeof obj === 'object' && obj.join === undefined) {
|
||||||
stringArray.push('{');
|
stringArray.push('{');
|
||||||
for (const prop of Object.keys(obj)) {
|
for (const prop of Object.keys(obj)) {
|
||||||
stringArray.push(prop, ': ', convertToText(obj[prop]), ',');
|
stringArray.push(prop, ': ', convertToText(obj[prop]), ',');
|
||||||
@ -181,6 +164,9 @@ export class TsTest {
|
|||||||
|
|
||||||
return stringArray.join('');
|
return stringArray.join('');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let logStore = '';
|
||||||
|
// tslint:disable-next-line: max-classes-per-file
|
||||||
const log = console.log.bind(console);
|
const log = console.log.bind(console);
|
||||||
console.log = (...args) => {
|
console.log = (...args) => {
|
||||||
args = args.map((argument) => {
|
args = args.map((argument) => {
|
||||||
@ -197,28 +183,40 @@ export class TsTest {
|
|||||||
logStore += `${args}\n`;
|
logStore += `${args}\n`;
|
||||||
error(...args);
|
error(...args);
|
||||||
};
|
};
|
||||||
const bundle = await (await fetch('/test__test.browser.ts.js')).text();
|
const bundleName = new URLSearchParams(window.location.search).get('bundleName');
|
||||||
try {
|
console.log(`::TSTEST IN CHROMIUM:: Relevant Script name is: ${bundleName}`);
|
||||||
|
const bundleResponse = await fetch(`/${bundleName}`);
|
||||||
|
console.log(
|
||||||
|
`::TSTEST IN CHROMIUM:: Got ${bundleName} with STATUS ${bundleResponse.status}`
|
||||||
|
);
|
||||||
|
const bundle = await bundleResponse.text();
|
||||||
|
console.log(`::TSTEST IN CHROMIUM:: Executing ${bundleName}`);
|
||||||
|
try {
|
||||||
// tslint:disable-next-line: no-eval
|
// tslint:disable-next-line: no-eval
|
||||||
eval(bundle);
|
eval(bundle);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
|
||||||
console.log(globalThis.testdom);
|
if (
|
||||||
done.resolve();
|
(globalThis as any).tapbundleDeferred &&
|
||||||
}, 5000);
|
(globalThis as any).tapbundleDeferred.promise
|
||||||
await done.promise;
|
) {
|
||||||
|
await (globalThis as any).tapbundleDeferred.promise;
|
||||||
|
} else {
|
||||||
|
console.log('Error: Could not find tapbundle Deferred');
|
||||||
|
}
|
||||||
return logStore;
|
return logStore;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
await plugins.smartdelay.delayFor(1000);
|
|
||||||
await this.smartbrowserInstance.stop();
|
await this.smartbrowserInstance.stop();
|
||||||
console.log(`${cs('=> ', 'blue')} Stopped ${cs(fileNameArg, 'orange')} chromium instance.`);
|
|
||||||
await server.stop();
|
await server.stop();
|
||||||
console.log(`${cs('=> ', 'blue')} Stopped ${cs(fileNameArg, 'orange')} server.`);
|
console.log(
|
||||||
|
`${cs('=> ', 'blue')} Stopped ${cs(fileNameArg, 'orange')} chromium instance and server.`
|
||||||
|
);
|
||||||
|
console.log(`${cs('=> ', 'blue')} See the result captured from the chromium execution:`);
|
||||||
// lets create the tap parser
|
// lets create the tap parser
|
||||||
const tapParser = new TapParser(fileNameArg);
|
const tapParser = new TapParser(fileNameArg + ':chrome');
|
||||||
tapParser.handleTapLog(evaluation);
|
tapParser.handleTapLog(evaluation);
|
||||||
return tapParser;
|
return tapParser;
|
||||||
}
|
}
|
||||||
|
@ -12,15 +12,24 @@ 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';
|
||||||
|
import * as tapbundle from '@pushrocks/tapbundle';
|
||||||
|
|
||||||
export { consolecolor, smartbrowser, smartexpress, smartdelay, smartfile, smartlog, smartpromise, smartshell };
|
export {
|
||||||
|
consolecolor,
|
||||||
|
smartbrowser,
|
||||||
|
smartexpress,
|
||||||
|
smartdelay,
|
||||||
|
smartfile,
|
||||||
|
smartlog,
|
||||||
|
smartpromise,
|
||||||
|
smartshell,
|
||||||
|
tapbundle,
|
||||||
|
};
|
||||||
|
|
||||||
// @gitzone scope
|
// @gitzone scope
|
||||||
import * as tsbundle from '@gitzone/tsbundle';
|
import * as tsbundle from '@gitzone/tsbundle';
|
||||||
|
|
||||||
export {
|
export { tsbundle };
|
||||||
tsbundle
|
|
||||||
};
|
|
||||||
|
|
||||||
// sindresorhus
|
// sindresorhus
|
||||||
import * as figures from 'figures';
|
import * as figures from 'figures';
|
||||||
|
Reference in New Issue
Block a user