Skip to content

Commit

Permalink
fix!: clean up setupToolboxTester
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
ph-fritsche committed Dec 29, 2024
1 parent 03dd8e0 commit 8bd47b0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 49 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ For the "default" usage there are setup functions that reduce the boilerplate.
```js
import { setupSourceModuleLoader, setupToolboxTester, setupNodeConductor, setupChromeConductor, serveDir } from '@ph.fritsche/toolbox'

const tester = await setupToolboxTester(
const {cli} = await setupToolboxTester(
[ // Watched files
'src',
'test'
Expand All @@ -32,7 +32,7 @@ const tester = await setupToolboxTester(
)

// Run the tests with each of the conductors and report combined results
await tester.start()
await cli.start()
```

## Design
Expand Down
47 changes: 0 additions & 47 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {TestFile, TestRunStack, TestSuite } from './conductor/TestRun'
import { TestRunIterator } from './conductor/TestRunIterator'
import { PackageConfigResolver } from './loader/PackageConfigResolver'
import { CjsTransformer } from './loader/CjsTransformer'
import { ConsoleReporter } from './reporter/ConsoleReporter'
import { FsLoader } from './loader/FsLoader'
import { NodeTestConductor } from './conductor/NodeTestConductor'
import { ChromeTestConductor } from './conductor/ChromeTestConductor'
Expand Down Expand Up @@ -278,7 +277,6 @@ export async function setupToolboxTester(
testRunIterator = TestRunIterator.iterateSuitesByConductors,
watcherFactory = () => new FsWatcher(),
mapPathsToTestFiles = defaults.mapPathsToTestFiles,
connectConsoleReporter = true,
setExitCode = !!process.env.CI,
}: {
/**
Expand Down Expand Up @@ -321,12 +319,6 @@ export async function setupToolboxTester(
* (the URLs and titles of the {@link TestSuite}s).
*/
mapPathsToTestFiles?: (fileserverUrl: URL, subPaths: Iterable<string>) => Iterable<TestFile>
/**
* Automatically connect the default {@link ConsoleReporter} to test runs created on the {@link TestRunManager}.
*
* Defaults to `true`.
*/
connectConsoleReporter?: boolean
/**
* Set `process.exitCode` according to the test run results.
*
Expand Down Expand Up @@ -360,12 +352,6 @@ export async function setupToolboxTester(
conductors.push(c(runner.url))
}

const consoleReporter = new ConsoleReporter()
if (connectConsoleReporter) {
manager.addListener('create', ({run}) => consoleReporter.connect(run))
manager.addListener('done', ({run}) => consoleReporter.disconnect(run))
}

const tester = new Tester(
manager,
conductors,
Expand All @@ -376,36 +362,6 @@ export async function setupToolboxTester(
setExitCode,
)

const start = async ({
persistent = !process.env.CI,
}: {
persistent?: boolean
} = {}) => {
await tester.start()

if (!persistent) {
void close()
}
}

const close = async (closeConductors = true) => {
await tester.stop()

await watcher.close()

const a = []
if (closeConductors) {
for (const c of conductors) {
a.push(c.close())
}
a.push(runner.close())
}
a.push(fileServer.close())
await Promise.allSettled(a)

await tester[Symbol.asyncDispose]()
}

const cli = new TesterCli(tester)
cli.onClose(async() => {
await watcher.close()
Expand Down Expand Up @@ -448,9 +404,6 @@ export async function setupToolboxTester(
fileProvider,
fileServer,
watcher,
consoleReporter,
connectCoverageReporter,
start,
close,
}
}

0 comments on commit 8bd47b0

Please sign in to comment.