Compare commits
36 Commits
Author | SHA1 | Date | |
---|---|---|---|
4f35b101ec | |||
549ae53a00 | |||
d9aa2984ef | |||
37e6d94c9f | |||
74e1df6824 | |||
6eb86c63c3 | |||
e919a4a2e9 | |||
85f6703696 | |||
4c2812f671 | |||
bab93448e8 | |||
3db913eb59 | |||
28e0c32944 | |||
0be6b3400a | |||
eeba113e09 | |||
19e45b305c | |||
f9f4150cff | |||
710548911e | |||
23f9a28fa0 | |||
e1d2f1fd68 | |||
3116c5a818 | |||
568772734b | |||
30525e7e55 | |||
f7483ef995 | |||
1460f97c52 | |||
dfac554303 | |||
1d751bdcdf | |||
bd6713eee8 | |||
440b41611b | |||
78a40de700 | |||
e0eb00d755 | |||
dbbcbf4ea2 | |||
8c13b9db89 | |||
f813a79124 | |||
766138aa25 | |||
72880b4a2d | |||
bd5731c439 |
@ -12,29 +12,25 @@ stages:
|
||||
- release
|
||||
- metadata
|
||||
|
||||
before_script:
|
||||
- pnpm install -g pnpm
|
||||
- pnpm install -g @shipzone/npmci
|
||||
- npmci npm prepare
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
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
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command pnpm audit --audit-level=high --prod
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
@ -42,11 +38,10 @@ auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
- npmci command pnpm audit --audit-level=high --dev
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
@ -57,7 +52,6 @@ auditDevDependencies:
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
@ -68,7 +62,6 @@ testStable:
|
||||
testBuild:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
@ -97,10 +90,9 @@ codequality:
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci command npm install -g typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
@ -120,11 +112,9 @@ trigger:
|
||||
pages:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command tsdoc
|
||||
- npmci command npm run buildDocs
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
|
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -2,28 +2,10 @@
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "current file",
|
||||
"type": "node",
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"${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"
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
4
cli.child.ts
Normal file
4
cli.child.ts
Normal file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env node
|
||||
process.env.CLI_CALL = 'true';
|
||||
import * as cliTool from './ts/index.js';
|
||||
cliTool.runCli();
|
2
cli.js
2
cli.js
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env node
|
||||
process.env.CLI_CALL = 'true';
|
||||
const cliTool = require('./dist_ts/index');
|
||||
const cliTool = await import('./dist_ts/index.js');
|
||||
cliTool.runCli();
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
process.env.CLI_CALL = 'true';
|
||||
require('@gitzone/tsrun');
|
||||
const cliTool = require('./ts/index');
|
||||
cliTool.runCli();
|
||||
|
||||
import * as tsrun from '@gitzone/tsrun';
|
||||
tsrun.runPath('./cli.child.js', import.meta.url);
|
||||
|
@ -1,3 +0,0 @@
|
||||
# How to contribute
|
||||
|
||||
Start with `tstest.classes.tstest.ts` to understand whats happening
|
@ -9,7 +9,7 @@
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "gitzone",
|
||||
"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",
|
||||
"license": "MIT"
|
||||
}
|
||||
|
23482
package-lock.json
generated
23482
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
36
package.json
36
package.json
@ -1,10 +1,11 @@
|
||||
{
|
||||
"name": "@gitzone/tstest",
|
||||
"version": "1.0.59",
|
||||
"version": "1.0.77",
|
||||
"private": false,
|
||||
"description": "a test utility to run tests that match test/**/*.ts",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
@ -15,27 +16,26 @@
|
||||
"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/ --web",
|
||||
"cleanUp": "rm -rf .nogit/sandbox-npmts",
|
||||
"build": "(tsbuild --web)"
|
||||
"build": "(tsbuild --web --allowimplicitany --skiplibcheck)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.28",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
"@gitzone/tsbuild": "^2.1.66",
|
||||
"@types/node": "^20.4.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@gitzone/tsbundle": "^1.0.88",
|
||||
"@gitzone/tsrun": "^1.2.18",
|
||||
"@pushrocks/consolecolor": "^2.0.1",
|
||||
"@pushrocks/smartbrowser": "^1.0.17",
|
||||
"@pushrocks/smartdelay": "^2.0.13",
|
||||
"@pushrocks/smartexpress": "^3.0.107",
|
||||
"@pushrocks/smartfile": "^8.0.10",
|
||||
"@pushrocks/smartlog": "^2.0.44",
|
||||
"@pushrocks/smartpromise": "^3.1.6",
|
||||
"@pushrocks/smartshell": "^2.0.28",
|
||||
"@pushrocks/tapbundle": "^3.2.14",
|
||||
"@types/figures": "^3.0.1",
|
||||
"figures": "^3.0.0"
|
||||
"@apiglobal/typedserver": "^2.0.65",
|
||||
"@gitzone/tsbundle": "^2.0.8",
|
||||
"@gitzone/tsrun": "^1.2.43",
|
||||
"@push.rocks/consolecolor": "^2.0.1",
|
||||
"@push.rocks/smartbrowser": "^2.0.5",
|
||||
"@push.rocks/smartdelay": "^3.0.2",
|
||||
"@push.rocks/smartfile": "^10.0.28",
|
||||
"@push.rocks/smartlog": "^3.0.3",
|
||||
"@push.rocks/smartpromise": "^4.0.3",
|
||||
"@push.rocks/smartshell": "^3.0.3",
|
||||
"@push.rocks/tapbundle": "^5.0.12",
|
||||
"figures": "^5.0.0"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
|
4726
pnpm-lock.yaml
generated
Normal file
4726
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
24
readme.md
24
readme.md
@ -25,9 +25,29 @@ Platform support | [ or [contribute monthly](https://lossless.link/contribute). :)
|
||||
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
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as tstest from '../ts/index';
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
import * as tstest from '../ts/index.js';
|
||||
|
||||
tap.test('prepare test', async () => {});
|
||||
|
||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@gitzone/tstest',
|
||||
version: '1.0.77',
|
||||
description: 'a test utility to run tests that match test/**/*.ts'
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import { TsTest } from './tstest.classes.tstest';
|
||||
import { TsTest } from './tstest.classes.tstest.js';
|
||||
|
||||
export const runCli = async () => {
|
||||
if (!process.argv[2]) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
// ============
|
||||
// combines different tap test files to an overall result
|
||||
// ============
|
||||
import * as plugins from './tstest.plugins';
|
||||
import { coloredString as cs } from '@pushrocks/consolecolor';
|
||||
import * as plugins from './tstest.plugins.js';
|
||||
import { coloredString as cs } from '@push.rocks/consolecolor';
|
||||
|
||||
import { TapParser } from './tstest.classes.tap.parser';
|
||||
import * as logPrefixes from './tstest.logprefixes';
|
||||
import { TapParser } from './tstest.classes.tap.parser.js';
|
||||
import * as logPrefixes from './tstest.logprefixes.js';
|
||||
|
||||
export class TapCombinator {
|
||||
tapParserStore: TapParser[] = [];
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { ChildProcess } from 'child_process';
|
||||
import { coloredString as cs } from '@pushrocks/consolecolor';
|
||||
import { coloredString as cs } from '@push.rocks/consolecolor';
|
||||
|
||||
// ============
|
||||
// combines different tap test files to an overall result
|
||||
// ============
|
||||
import * as plugins from './tstest.plugins';
|
||||
import { TapTestResult } from './tstest.classes.tap.testresult';
|
||||
import * as logPrefixes from './tstest.logprefixes';
|
||||
import * as plugins from './tstest.plugins.js';
|
||||
import { TapTestResult } from './tstest.classes.tap.testresult.js';
|
||||
import * as logPrefixes from './tstest.logprefixes.js';
|
||||
|
||||
export class TapParser {
|
||||
testStore: TapTestResult[] = [];
|
||||
|
@ -1,7 +1,7 @@
|
||||
// ============
|
||||
// combines different tap test files to an overall result
|
||||
// ============
|
||||
import * as plugins from './tstest.plugins';
|
||||
import * as plugins from './tstest.plugins.js';
|
||||
|
||||
export class TapTestResult {
|
||||
testLogBuffer = Buffer.from('');
|
||||
|
@ -1,11 +1,11 @@
|
||||
import * as plugins from './tstest.plugins';
|
||||
import * as paths from './tstest.paths';
|
||||
import { Smartfile } from '@pushrocks/smartfile';
|
||||
import * as plugins from './tstest.plugins.js';
|
||||
import * as paths from './tstest.paths.js';
|
||||
import { Smartfile } from '@push.rocks/smartfile';
|
||||
|
||||
// tap related stuff
|
||||
import { TapCombinator } from './tstest.classes.tap.combinator';
|
||||
import { TapParser } from './tstest.classes.tap.parser';
|
||||
import { TapTestResult } from './tstest.classes.tap.testresult';
|
||||
import { TapCombinator } from './tstest.classes.tap.combinator.js';
|
||||
import { TapParser } from './tstest.classes.tap.parser.js';
|
||||
import { TapTestResult } from './tstest.classes.tap.testresult.js';
|
||||
|
||||
export class TestDirectory {
|
||||
/**
|
||||
|
@ -1,12 +1,12 @@
|
||||
import * as plugins from './tstest.plugins';
|
||||
import * as paths from './tstest.paths';
|
||||
import * as logPrefixes from './tstest.logprefixes';
|
||||
import * as plugins from './tstest.plugins.js';
|
||||
import * as paths from './tstest.paths.js';
|
||||
import * as logPrefixes from './tstest.logprefixes.js';
|
||||
|
||||
import { coloredString as cs } from '@pushrocks/consolecolor';
|
||||
import { coloredString as cs } from '@push.rocks/consolecolor';
|
||||
|
||||
import { TestDirectory } from './tstest.classes.testdirectory';
|
||||
import { TapCombinator } from './tstest.classes.tap.combinator';
|
||||
import { TapParser } from './tstest.classes.tap.parser';
|
||||
import { TestDirectory } from './tstest.classes.testdirectory.js';
|
||||
import { TapCombinator } from './tstest.classes.tap.combinator.js';
|
||||
import { TapParser } from './tstest.classes.tap.parser.js';
|
||||
|
||||
export class TsTest {
|
||||
public testDir: TestDirectory;
|
||||
@ -41,15 +41,15 @@ export class TsTest {
|
||||
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`
|
||||
`not running testfile ${fileNameArg}, since we are CI and file name includes '.nonci.' tag`
|
||||
);
|
||||
console.log('!!!!!!!!!!!');
|
||||
break;
|
||||
case fileNameArg.endsWith('.browser.ts'):
|
||||
case fileNameArg.endsWith('.browser.ts') || fileNameArg.endsWith('.browser.nonci.ts'):
|
||||
const tapParserBrowser = await this.runInChrome(fileNameArg);
|
||||
tapCombinator.addTapParser(tapParserBrowser);
|
||||
break;
|
||||
case fileNameArg.endsWith('.both.ts'):
|
||||
case fileNameArg.endsWith('.both.ts') || fileNameArg.endsWith('.both.nonci.ts'):
|
||||
console.log('>>>>>>> TEST PART 1: chrome');
|
||||
const tapParserBothBrowser = await this.runInChrome(fileNameArg);
|
||||
tapCombinator.addTapParser(tapParserBothBrowser);
|
||||
@ -99,17 +99,19 @@ export class TsTest {
|
||||
const bundleFilePath = plugins.path.join(tsbundleCacheDirPath, bundleFileName);
|
||||
|
||||
// lets bundle the test
|
||||
await plugins.smartfile.fs.ensureDir(tsbundleCacheDirPath);
|
||||
await this.tsbundleInstance.buildTest(process.cwd(), fileNameArg, bundleFilePath, 'parcel');
|
||||
await plugins.smartfile.fs.ensureEmptyDir(tsbundleCacheDirPath);
|
||||
await this.tsbundleInstance.build(process.cwd(), fileNameArg, bundleFilePath, {
|
||||
bundler: 'esbuild',
|
||||
});
|
||||
|
||||
// lets create a server
|
||||
const server = new plugins.smartexpress.Server({
|
||||
const server = new plugins.typedserver.servertools.Server({
|
||||
cors: true,
|
||||
port: 3007,
|
||||
});
|
||||
server.addRoute(
|
||||
'/test',
|
||||
new plugins.smartexpress.Handler('GET', async (req, res) => {
|
||||
new plugins.typedserver.servertools.Handler('GET', async (req, res) => {
|
||||
res.type('.html');
|
||||
res.write(`
|
||||
<html>
|
||||
@ -124,7 +126,7 @@ export class TsTest {
|
||||
res.end();
|
||||
})
|
||||
);
|
||||
server.addRoute('*', new plugins.smartexpress.HandlerStatic(tsbundleCacheDirPath));
|
||||
server.addRoute('*', new plugins.typedserver.servertools.HandlerStatic(tsbundleCacheDirPath));
|
||||
await server.start();
|
||||
|
||||
// lets do the browser bit
|
||||
@ -134,7 +136,7 @@ export class TsTest {
|
||||
async () => {
|
||||
const convertToText = (obj: any): string => {
|
||||
// create an array that will later be joined into a string.
|
||||
const stringArray = [];
|
||||
const stringArray: string[] = [];
|
||||
|
||||
if (typeof obj === 'object' && typeof obj.toString === 'function') {
|
||||
stringArray.push(obj.toString());
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as plugins from './tstest.plugins';
|
||||
import { coloredString as cs } from '@pushrocks/consolecolor';
|
||||
import * as plugins from './tstest.plugins.js';
|
||||
import { coloredString as cs } from '@push.rocks/consolecolor';
|
||||
|
||||
export const TapPrefix = cs(`::TAP::`, 'pink', 'black');
|
||||
export const TapErrorPrefix = cs(` !!!TAP PROTOCOL ERROR!!! `, 'red', 'black');
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as plugins from './tstest.plugins';
|
||||
import * as plugins from './tstest.plugins.js';
|
||||
|
||||
export const cwd = process.cwd();
|
||||
export const testDir = plugins.path.join(cwd, './test/');
|
||||
export const binDirectory = plugins.path.join(cwd, 'node_modules/.bin');
|
||||
export const binDirectory = plugins.path.join(cwd, './node_modules/.bin');
|
||||
|
@ -3,21 +3,26 @@ import * as path from 'path';
|
||||
|
||||
export { path };
|
||||
|
||||
// @pushrocks scope
|
||||
import * as consolecolor from '@pushrocks/consolecolor';
|
||||
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 smartlog from '@pushrocks/smartlog';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartshell from '@pushrocks/smartshell';
|
||||
import * as tapbundle from '@pushrocks/tapbundle';
|
||||
// @apiglobal scope
|
||||
import * as typedserver from '@apiglobal/typedserver';
|
||||
|
||||
export {
|
||||
typedserver
|
||||
}
|
||||
|
||||
// @push.rocks scope
|
||||
import * as consolecolor from '@push.rocks/consolecolor';
|
||||
import * as smartbrowser from '@push.rocks/smartbrowser';
|
||||
import * as smartdelay from '@push.rocks/smartdelay';
|
||||
import * as smartfile from '@push.rocks/smartfile';
|
||||
import * as smartlog from '@push.rocks/smartlog';
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
import * as smartshell from '@push.rocks/smartshell';
|
||||
import * as tapbundle from '@push.rocks/tapbundle';
|
||||
|
||||
export {
|
||||
consolecolor,
|
||||
smartbrowser,
|
||||
smartexpress,
|
||||
smartdelay,
|
||||
smartfile,
|
||||
smartlog,
|
||||
@ -32,6 +37,6 @@ import * as tsbundle from '@gitzone/tsbundle';
|
||||
export { tsbundle };
|
||||
|
||||
// sindresorhus
|
||||
import * as figures from 'figures';
|
||||
import figures from 'figures';
|
||||
|
||||
export { figures };
|
||||
|
11
tsconfig.json
Normal file
11
tsconfig.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "nodenext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
}
|
||||
}
|
17
tslint.json
17
tslint.json
@ -1,17 +0,0 @@
|
||||
{
|
||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||
"rules": {
|
||||
"semicolon": [true, "always"],
|
||||
"no-console": false,
|
||||
"ordered-imports": false,
|
||||
"object-literal-sort-keys": false,
|
||||
"member-ordering": {
|
||||
"options":{
|
||||
"order": [
|
||||
"static-method"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultSeverity": "warning"
|
||||
}
|
Reference in New Issue
Block a user