Skip to content

Commit

Permalink
Merge branch 'master' into feature/AG-22709
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamWr committed May 31, 2023
2 parents 5990342 + fdade01 commit 27e2c8b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 17 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,14 @@ yarn test
yarn test:qunit redirects --name ati-smarttag --gui
```

For debugging purposes after some test is running in gui mode,
you may change your scriptlet/redirect code, and without stopping the server
run in new terminal:

```bash
yarn test:qunit scriptlets --name set-cookie --build
```

1. Run all jest tests:

```bash
Expand Down
10 changes: 4 additions & 6 deletions bamboo-specs/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,16 @@ Build:
yarn install
# check compatibility table updates and build it
# build docs to lint them later
# 1. check compatibility table updates and build it
yarn wiki:build-table
# build other wiki docs
# 2. build other wiki docs
yarn wiki:build-docs
# lint docs
yarn lint:md
yarn test
yarn build
# lint code. it should be run after yarn build
# lint code and docs. it should be run after yarn build
yarn lint
rm -rf node_modules
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adguard/scriptlets",
"version": "1.9.30",
"version": "1.9.31",
"description": "AdGuard's JavaScript library of Scriptlets and Redirect resources",
"scripts": {
"build": "babel-node scripts/build.js",
Expand Down
29 changes: 19 additions & 10 deletions scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { buildScriptlets, buildScriptletsList } from './build-scriptlets';
import { buildScriptletsFunc } from './build-funcs';
import { buildRedirectsMap } from './build-redirects-map';
import {
buildClick2Load,
buildRedirectsFiles,
buildRedirectsList,
prebuildRedirects,
Expand Down Expand Up @@ -42,6 +43,7 @@ const runGuiTest = async (type, name) => {
const allBuildTestTasks = [
buildScriptletsAndRedirectsLists,
buildScriptletsFunc,
buildClick2Load,
buildRedirectsMap,
prebuildRedirects,
buildRedirectsFiles,
Expand Down Expand Up @@ -78,12 +80,20 @@ const runSpecificTests = async (type, options) => {
await runTasks(buildTasksMap[type]);

const limitData = { type };
const { name, gui } = options;
const { name, gui, build } = options;
if (name) {
limitData.name = name;
}
await buildTests(limitData);

// do not run tests for --build
if (build) {
if (gui) {
throw new Error('Cannot use --build with --gui');
}
return;
}

// gui testing is available only for specific scriptlet or redirect
if (gui && name) {
await runGuiTest(type, name);
Expand All @@ -94,24 +104,22 @@ const runSpecificTests = async (type, options) => {

program
.description('By default run all tests')
.action(async () => {
await runTasks(allBuildTestTasks);
await buildTests();
await runQunitTests();
});

program
.description('Just build tests files, no run')
.option('--build', 'only build')
.action(async () => {
.action(async (options) => {
await runTasks(allBuildTestTasks);
await buildTests();
// if build option is set, then do not run tests
if (!options.build) {
await runQunitTests();
}
});

program
.description('Test only scriptlets')
.command('scriptlets')
.option('--name <name>', 'for specific scriptlet testing')
.option('--gui', 'for gui testing, requires --name')
.option('--build', 'build sources; requires --name; cannot be used with --gui')
.action(async (options) => {
await runSpecificTests(SCRIPTLETS_TYPE, options);
});
Expand All @@ -121,6 +129,7 @@ program
.command('redirects')
.option('--name <name>', 'for specific redirect testing')
.option('--gui', 'for gui testing, requires --name')
.option('--build', 'build sources; requires --name; cannot be used with --gui')
.action(async (options) => {
await runSpecificTests(REDIRECTS_TYPE, options);
});
Expand Down

0 comments on commit 27e2c8b

Please sign in to comment.