Skip to content

Commit

Permalink
add test watch
Browse files Browse the repository at this point in the history
  • Loading branch information
shamilovtim committed Dec 2, 2023
1 parent ae975ea commit 90b1901
Show file tree
Hide file tree
Showing 34 changed files with 226 additions and 53 deletions.
12 changes: 10 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ module.exports = {
'no-trailing-spaces' : ['error'],
'@typescript-eslint/no-non-null-assertion' : 'off',
'@typescript-eslint/ban-ts-comment' : 'off',
'mocha/no-exclusive-tests' : 'warn'
}
'mocha/no-exclusive-tests' : 'warn',
},
overrides: [
{
files : ['*.cjs'],
rules : {
'@typescript-eslint/no-var-requires': 'off'
}
}
]
};
1 change: 0 additions & 1 deletion packages/agent/build/esbuild-browser-config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const polyfillProviderPlugin = require('node-stdlib-browser/helpers/esbuild/plugin');
const stdLibBrowser = require('node-stdlib-browser');

Expand Down
24 changes: 21 additions & 3 deletions packages/agent/build/esbuild-tests.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const esbuild = require('esbuild');
const browserConfig = require('./esbuild-browser-config.cjs');

esbuild.build({
/** @type {import('esbuild').BuildOptions} */
let config = {
...browserConfig,
format : 'esm',
entryPoints : ['./tests/*.spec.*'],
Expand All @@ -13,4 +13,22 @@ esbuild.build({
...browserConfig.define,
'process.env.TEST_DWN_URL': JSON.stringify(process.env.TEST_DWN_URL ?? null),
},
});
};

const handleBuild = () => {
esbuild.build(config);
};

const handleWatch = async() => {
let ctx = await esbuild.context(config);

await ctx.watch();
};

const hasWatchArg = process.argv.includes('--watch');

if (hasWatchArg) {
handleWatch();
} else {
handleBuild();
}
4 changes: 3 additions & 1 deletion packages/agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
"build:browser": "rimraf dist/browser.mjs dist/browser.js && node build/bundles.js",
"build:tests:node": "rimraf tests/compiled && tsc -p tests/tsconfig.json",
"build:tests:browser": "rimraf tests/compiled && node build/esbuild-tests.cjs",
"build:tests:browser:watch": "rimraf tests/compiled && node build/esbuild-tests.cjs --watch &",
"build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:browser",
"lint": "eslint . --ext .ts --max-warnings 0",
"lint:fix": "eslint . --ext .ts --fix",
"test:node": "npm run build:tests:node && c8 mocha",
"test:browser": "npm run build:tests:browser && web-test-runner"
"test:browser": "npm run build:tests:browser && web-test-runner",
"test:browser:watch": "(npm run build:tests:browser:watch && web-test-runner --watch) || killall esbuild"
},
"homepage": "https://github.com/TBD54566975/web5-js/tree/main/packages/agent#readme",
"bugs": "https://github.com/TBD54566975/web5-js/issues",
Expand Down
1 change: 0 additions & 1 deletion packages/agent/web-test-runner.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const playwrightLauncher =
require('@web/test-runner-playwright').playwrightLauncher;

Expand Down
1 change: 0 additions & 1 deletion packages/api/build/esbuild-browser-config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const polyfillProviderPlugin = require('node-stdlib-browser/helpers/esbuild/plugin');
const stdLibBrowser = require('node-stdlib-browser');

Expand Down
24 changes: 21 additions & 3 deletions packages/api/build/esbuild-tests.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const esbuild = require('esbuild');
const browserConfig = require('./esbuild-browser-config.cjs');

esbuild.build({
/** @type {import('esbuild').BuildOptions} */
let config = {
...browserConfig,
format : 'esm',
entryPoints : ['./tests/*.spec.*'],
Expand All @@ -13,4 +13,22 @@ esbuild.build({
...browserConfig.define,
'process.env.TEST_DWN_URL': JSON.stringify(process.env.TEST_DWN_URL ?? null),
},
});
};

const handleBuild = () => {
esbuild.build(config);
};

const handleWatch = async() => {
let ctx = await esbuild.context(config);

await ctx.watch();
};

const hasWatchArg = process.argv.includes('--watch');

if (hasWatchArg) {
handleWatch();
} else {
handleBuild();
}
4 changes: 3 additions & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
"build:browser": "rimraf dist/browser.mjs dist/browser.js && node build/bundles.js",
"build:tests:node": "rimraf tests/compiled && tsc -p tests/tsconfig.json",
"build:tests:browser": "rimraf tests/compiled && node build/esbuild-tests.cjs",
"build:tests:browser:watch": "rimraf tests/compiled && node build/esbuild-tests.cjs --watch &",
"build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:browser",
"lint": "eslint . --ext .ts --max-warnings 0",
"lint:fix": "eslint . --ext .ts --fix",
"test:node": "npm run build:tests:node && c8 mocha",
"test:browser": "npm run build:tests:browser && web-test-runner"
"test:browser": "npm run build:tests:browser && web-test-runner",
"test:browser:watch": "(npm run build:tests:browser:watch && web-test-runner --watch) || killall esbuild"
},
"homepage": "https://github.com/TBD54566975/web5-js/tree/main/packages/api#readme",
"bugs": "https://github.com/TBD54566975/web5-js/issues",
Expand Down
1 change: 0 additions & 1 deletion packages/api/web-test-runner.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const playwrightLauncher =
require('@web/test-runner-playwright').playwrightLauncher;

Expand Down
24 changes: 21 additions & 3 deletions packages/common/build/esbuild-tests.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const esbuild = require('esbuild');
const browserConfig = require('./esbuild-browser-config.cjs');

esbuild.build({
/** @type {import('esbuild').BuildOptions} */
let config = {
...browserConfig,
format : 'esm',
entryPoints : ['./tests/*.spec.*'],
Expand All @@ -13,4 +13,22 @@ esbuild.build({
...browserConfig.define,
'process.env.TEST_DWN_URL': JSON.stringify(process.env.TEST_DWN_URL ?? null),
},
});
};

const handleBuild = () => {
esbuild.build(config);
};

const handleWatch = async() => {
let ctx = await esbuild.context(config);

await ctx.watch();
};

const hasWatchArg = process.argv.includes('--watch');

if (hasWatchArg) {
handleWatch();
} else {
handleBuild();
}
4 changes: 3 additions & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
"build:browser": "rimraf dist/browser.mjs dist/browser.js && node build/bundles.js",
"build:tests:node": "rimraf tests/compiled && tsc -p tests/tsconfig.json",
"build:tests:browser": "rimraf tests/compiled && node build/esbuild-tests.cjs",
"build:tests:browser:watch": "rimraf tests/compiled && node build/esbuild-tests.cjs --watch &",
"build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:browser",
"lint": "eslint . --ext .ts --max-warnings 0",
"lint:fix": "eslint . --ext .ts --fix",
"test:node": "npm run build:tests:node && c8 mocha",
"test:browser": "npm run build:tests:browser && web-test-runner"
"test:browser": "npm run build:tests:browser && web-test-runner",
"test:browser:watch": "(npm run build:tests:browser:watch && web-test-runner --watch) || killall esbuild"
},
"homepage": "https://github.com/TBD54566975/web5-js/tree/main/packages/common#readme",
"bugs": "https://github.com/TBD54566975/web5-js/issues",
Expand Down
1 change: 0 additions & 1 deletion packages/common/web-test-runner.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const playwrightLauncher =
require('@web/test-runner-playwright').playwrightLauncher;

Expand Down
24 changes: 21 additions & 3 deletions packages/credentials/build/esbuild-tests.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const esbuild = require('esbuild');
const browserConfig = require('./esbuild-browser-config.cjs');

esbuild.build({
/** @type {import('esbuild').BuildOptions} */
let config = {
...browserConfig,
format : 'esm',
entryPoints : ['./tests/*.spec.*'],
Expand All @@ -13,4 +13,22 @@ esbuild.build({
...browserConfig.define,
'process.env.TEST_DWN_URL': JSON.stringify(process.env.TEST_DWN_URL ?? null),
},
});
};

const handleBuild = () => {
esbuild.build(config);
};

const handleWatch = async() => {
let ctx = await esbuild.context(config);

await ctx.watch();
};

const hasWatchArg = process.argv.includes('--watch');

if (hasWatchArg) {
handleWatch();
} else {
handleBuild();
}
4 changes: 3 additions & 1 deletion packages/credentials/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
"build:browser": "rimraf dist/browser.mjs dist/browser.js && node build/bundles.js",
"build:tests:node": "rimraf tests/compiled && tsc -p tests/tsconfig.json",
"build:tests:browser": "rimraf tests/compiled && node build/esbuild-tests.cjs",
"build:tests:browser:watch": "rimraf tests/compiled && node build/esbuild-tests.cjs --watch &",
"build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:browser",
"lint": "eslint . --ext .ts --max-warnings 0",
"lint:fix": "eslint . --ext .ts --fix",
"test:node": "npm run build:tests:node && c8 mocha",
"test:browser": "npm run build:tests:browser && web-test-runner"
"test:browser": "npm run build:tests:browser && web-test-runner",
"test:browser:watch": "(npm run build:tests:browser:watch && web-test-runner --watch) || killall esbuild"
},
"homepage": "https://github.com/TBD54566975/web5-js/tree/main/packages/credentials#readme",
"bugs": "https://github.com/TBD54566975/web5-js/issues",
Expand Down
1 change: 0 additions & 1 deletion packages/credentials/web-test-runner.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const playwrightLauncher =
require('@web/test-runner-playwright').playwrightLauncher;

Expand Down
24 changes: 21 additions & 3 deletions packages/crypto/build/esbuild-tests.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const esbuild = require('esbuild');
const browserConfig = require('./esbuild-browser-config.cjs');

esbuild.build({
/** @type {import('esbuild').BuildOptions} */
let config = {
...browserConfig,
format : 'esm',
entryPoints : ['./tests/*.spec.*'],
Expand All @@ -13,4 +13,22 @@ esbuild.build({
...browserConfig.define,
'process.env.TEST_DWN_URL': JSON.stringify(process.env.TEST_DWN_URL ?? null),
},
});
};

const handleBuild = () => {
esbuild.build(config);
};

const handleWatch = async() => {
let ctx = await esbuild.context(config);

await ctx.watch();
};

const hasWatchArg = process.argv.includes('--watch');

if (hasWatchArg) {
handleWatch();
} else {
handleBuild();
}
4 changes: 3 additions & 1 deletion packages/crypto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
"build:browser": "rimraf dist/browser.mjs dist/browser.js && node build/bundles.js",
"build:tests:node": "rimraf tests/compiled && tsc -p tests/tsconfig.json",
"build:tests:browser": "rimraf tests/compiled && node build/esbuild-tests.cjs",
"build:tests:browser:watch": "rimraf tests/compiled && node build/esbuild-tests.cjs --watch &",
"build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:browser",
"lint": "eslint . --ext .ts --max-warnings 0",
"lint:fix": "eslint . --ext .ts --fix",
"test:node": "npm run build:tests:node && c8 mocha",
"test:browser": "npm run build:tests:browser && web-test-runner"
"test:browser": "npm run build:tests:browser && web-test-runner",
"test:browser:watch": "(npm run build:tests:browser:watch && web-test-runner --watch) || killall esbuild"
},
"homepage": "https://github.com/TBD54566975/web5-js/tree/main/packages/crypto#readme",
"bugs": "https://github.com/TBD54566975/web5-js/issues",
Expand Down
1 change: 0 additions & 1 deletion packages/crypto/web-test-runner.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const playwrightLauncher =
require('@web/test-runner-playwright').playwrightLauncher;

Expand Down
1 change: 0 additions & 1 deletion packages/dids/build/buffer-polyfill.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const polyfilledBuffer = require('buffer/').Buffer;
const { Buffer } = require('buffer');

Expand Down
24 changes: 21 additions & 3 deletions packages/dids/build/esbuild-tests.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const esbuild = require('esbuild');
const browserConfig = require('./esbuild-browser-config.cjs');

esbuild.build({
/** @type {import('esbuild').BuildOptions} */
let config = {
...browserConfig,
format : 'esm',
entryPoints : ['./tests/*.spec.*'],
Expand All @@ -13,4 +13,22 @@ esbuild.build({
...browserConfig.define,
'process.env.TEST_DWN_URL': JSON.stringify(process.env.TEST_DWN_URL ?? null),
},
});
};

const handleBuild = () => {
esbuild.build(config);
};

const handleWatch = async() => {
let ctx = await esbuild.context(config);

await ctx.watch();
};

const hasWatchArg = process.argv.includes('--watch');

if (hasWatchArg) {
handleWatch();
} else {
handleBuild();
}
4 changes: 3 additions & 1 deletion packages/dids/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
"build:browser": "rimraf dist/browser.mjs dist/browser.js && node build/bundles.js",
"build:tests:node": "rimraf tests/compiled && tsc -p tests/tsconfig.json",
"build:tests:browser": "rimraf tests/compiled && node build/esbuild-tests.cjs",
"build:tests:browser:watch": "rimraf tests/compiled && node build/esbuild-tests.cjs --watch &",
"build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:browser",
"lint": "eslint . --ext .ts --max-warnings 0",
"lint:fix": "eslint . --ext .ts --fix",
"test:node": "npm run build:tests:node && c8 mocha",
"test:browser": "npm run build:tests:browser && web-test-runner"
"test:browser": "npm run build:tests:browser && web-test-runner",
"test:browser:watch": "(npm run build:tests:browser:watch && web-test-runner --watch) || killall esbuild"
},
"homepage": "https://github.com/TBD54566975/web5-js/tree/main/packages/dids#readme",
"bugs": "https://github.com/TBD54566975/web5-js/issues",
Expand Down
1 change: 0 additions & 1 deletion packages/dids/web-test-runner.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const playwrightLauncher =
require('@web/test-runner-playwright').playwrightLauncher;

Expand Down
1 change: 0 additions & 1 deletion packages/identity-agent/build/esbuild-browser-config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const polyfillProviderPlugin = require('node-stdlib-browser/helpers/esbuild/plugin');
const stdLibBrowser = require('node-stdlib-browser');

Expand Down
Loading

0 comments on commit 90b1901

Please sign in to comment.