Skip to content

Commit 8bd47b0

Browse files
committed
fix!: clean up setupToolboxTester
`start` and `close` functions and the `connectConsoleReporter` option have been removed. If you want to start the Tester with CLI output, use `cli.open()` instead.
1 parent 03dd8e0 commit 8bd47b0

File tree

2 files changed

+2
-49
lines changed

2 files changed

+2
-49
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ For the "default" usage there are setup functions that reduce the boilerplate.
1010
```js
1111
import { setupSourceModuleLoader, setupToolboxTester, setupNodeConductor, setupChromeConductor, serveDir } from '@ph.fritsche/toolbox'
1212

13-
const tester = await setupToolboxTester(
13+
const {cli} = await setupToolboxTester(
1414
[ // Watched files
1515
'src',
1616
'test'
@@ -32,7 +32,7 @@ const tester = await setupToolboxTester(
3232
)
3333

3434
// Run the tests with each of the conductors and report combined results
35-
await tester.start()
35+
await cli.start()
3636
```
3737

3838
## Design

src/index.ts

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {TestFile, TestRunStack, TestSuite } from './conductor/TestRun'
1111
import { TestRunIterator } from './conductor/TestRunIterator'
1212
import { PackageConfigResolver } from './loader/PackageConfigResolver'
1313
import { CjsTransformer } from './loader/CjsTransformer'
14-
import { ConsoleReporter } from './reporter/ConsoleReporter'
1514
import { FsLoader } from './loader/FsLoader'
1615
import { NodeTestConductor } from './conductor/NodeTestConductor'
1716
import { ChromeTestConductor } from './conductor/ChromeTestConductor'
@@ -278,7 +277,6 @@ export async function setupToolboxTester(
278277
testRunIterator = TestRunIterator.iterateSuitesByConductors,
279278
watcherFactory = () => new FsWatcher(),
280279
mapPathsToTestFiles = defaults.mapPathsToTestFiles,
281-
connectConsoleReporter = true,
282280
setExitCode = !!process.env.CI,
283281
}: {
284282
/**
@@ -321,12 +319,6 @@ export async function setupToolboxTester(
321319
* (the URLs and titles of the {@link TestSuite}s).
322320
*/
323321
mapPathsToTestFiles?: (fileserverUrl: URL, subPaths: Iterable<string>) => Iterable<TestFile>
324-
/**
325-
* Automatically connect the default {@link ConsoleReporter} to test runs created on the {@link TestRunManager}.
326-
*
327-
* Defaults to `true`.
328-
*/
329-
connectConsoleReporter?: boolean
330322
/**
331323
* Set `process.exitCode` according to the test run results.
332324
*
@@ -360,12 +352,6 @@ export async function setupToolboxTester(
360352
conductors.push(c(runner.url))
361353
}
362354

363-
const consoleReporter = new ConsoleReporter()
364-
if (connectConsoleReporter) {
365-
manager.addListener('create', ({run}) => consoleReporter.connect(run))
366-
manager.addListener('done', ({run}) => consoleReporter.disconnect(run))
367-
}
368-
369355
const tester = new Tester(
370356
manager,
371357
conductors,
@@ -376,36 +362,6 @@ export async function setupToolboxTester(
376362
setExitCode,
377363
)
378364

379-
const start = async ({
380-
persistent = !process.env.CI,
381-
}: {
382-
persistent?: boolean
383-
} = {}) => {
384-
await tester.start()
385-
386-
if (!persistent) {
387-
void close()
388-
}
389-
}
390-
391-
const close = async (closeConductors = true) => {
392-
await tester.stop()
393-
394-
await watcher.close()
395-
396-
const a = []
397-
if (closeConductors) {
398-
for (const c of conductors) {
399-
a.push(c.close())
400-
}
401-
a.push(runner.close())
402-
}
403-
a.push(fileServer.close())
404-
await Promise.allSettled(a)
405-
406-
await tester[Symbol.asyncDispose]()
407-
}
408-
409365
const cli = new TesterCli(tester)
410366
cli.onClose(async() => {
411367
await watcher.close()
@@ -448,9 +404,6 @@ export async function setupToolboxTester(
448404
fileProvider,
449405
fileServer,
450406
watcher,
451-
consoleReporter,
452407
connectCoverageReporter,
453-
start,
454-
close,
455408
}
456409
}

0 commit comments

Comments
 (0)