Skip to content

Commit 337c69c

Browse files
committed
tweaks
1 parent 94f0e33 commit 337c69c

3 files changed

Lines changed: 20 additions & 19 deletions

File tree

packages/scaffold/src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ async function main() {
5353
.description("Run tests")
5454
.option("--abort-on-fail", "Abort the test suite on first failure")
5555
.option("--exit-on-finish", "Exit the test suite after all tests have run")
56-
.option("--no-watch", "watch changes and re-run test")
56+
.option("--no-watch", "Exit the test suite after all tests have run")
5757
.action((options) => {
5858
process.env.NODE_ENV = "test";
5959

packages/scaffold/src/core/tester/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,14 @@ export default class Test extends Base {
5050
// Start a HTTP server to receive test results
5151
// This is useful for CI/CD environments
5252
await this.reporter.start();
53-
await this.ctx.hooks.callHook("test:listen", this.ctx);
5453

5554
// Create proxy plugin to run tests
5655
this.testBundler = new TestBundler(
5756
this.ctx,
5857
this.reporter.port,
5958
);
6059
await this.testBundler.generate();
61-
await this.ctx.hooks.callHook("test:copyAssets", this.ctx);
60+
await this.ctx.hooks.callHook("test:bundleTests", this.ctx);
6261

6362
// Start Zotero
6463
await this.startZotero();
@@ -131,6 +130,9 @@ export default class Test extends Base {
131130
}
132131

133132
private onZoteroExit = () => {
133+
this.reporter.stop();
134+
this.ctx.hooks.callHook("test:exit", this.ctx);
135+
134136
if (this.reporter.failed)
135137
process.exit(1);
136138
else

packages/scaffold/src/types/config.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,21 @@ export interface TestConfig {
642642
*/
643643
abortOnFail: boolean;
644644

645+
/**
646+
* Watch source and test file changes,
647+
* and re-run tests when files change.
648+
*
649+
* If this set to false, Zotero will exit
650+
* when test complated.
651+
*
652+
* 当源码或测试代码变更时自动重新运行测试。
653+
*
654+
* 若此选项设置为 false,Zotero 将在测试结束后立即退出。
655+
*
656+
* @default true (false in ci)
657+
*/
658+
watch: boolean;
659+
645660
/**
646661
* Run Zotero in deadless mode.
647662
*
@@ -684,28 +699,12 @@ export interface TestConfig {
684699
*/
685700
waitForPlugin: string;
686701

687-
/**
688-
* Watch source and test file changes,
689-
* and re-run tests when files change.
690-
*
691-
* If this set to false, Zotero will exit when test complated.
692-
*
693-
* 当源码或测试代码变更时自动重新运行测试。
694-
*
695-
* 若此选项设置为 false,Zotero 将在测试结束后立即退出。
696-
*
697-
* @default true (false in ci)
698-
*/
699-
watch: boolean;
700-
701702
hooks: Partial<TestHooks>;
702703
}
703704

704705
interface TestHooks {
705706
"test:init": (ctx: Context) => void | Promise<void>;
706707
"test:prebuild": (ctx: Context) => void | Promise<void>;
707-
"test:listen": (ctx: Context) => void | Promise<void>;
708-
"test:copyAssets": (ctx: Context) => void | Promise<void>;
709708
"test:bundleTests": (ctx: Context) => void | Promise<void>;
710709
"test:run": (ctx: Context) => void | Promise<void>;
711710
"test:exit": (ctx: Context) => void;

0 commit comments

Comments
 (0)