Skip to content

Commit

Permalink
fix: use path.resolve(), tidy output, add docs (#8)
Browse files Browse the repository at this point in the history
* fix: use path.resolve(), tidy output, add docs

* docs: fix docs
  • Loading branch information
nolanlawson authored Dec 17, 2021
1 parent 3fcf8c1 commit 00e9202
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,35 @@ If this function is not defined, then no setup code will be run.

#### createTests

The `createTests` function takes a Puppeteer [page][] as input and returns an array of plain objects representing the tests to run, and the data to pass for each one. This is useful if you want to dynamically determine what tests to run against a page (for instance, which links to click).
The `createTests` function takes a Puppeteer [page][] as input and returns an array of _test data objects_ representing the tests to run, and the data to pass for each one. This is useful if you want to dynamically determine what tests to run against a page (for instance, which links to click).

If this function is not defined, then the default tests are `[{}]` (a single test with empty data).
If `createTests` is not defined, then the default tests are `[{}]` (a single test with empty data).

The basic shape for a test data object is like so:

```json
{
"description": "Some human-readable description",
"data": {
"some data": "which is passed to the test"
}
}
```

For instance, your `createTests` might return:

```json
[
{
"description": "My test 1",
"data": { "foo": "foo" }
},
{
"description": "My test 2",
"data": { "foo": "bar" }
}
]
```

#### iteration

Expand Down
2 changes: 1 addition & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function main () {
const { signal } = controller
let scenario
if (options.scenario) {
scenario = await import(path.join(process.cwd(), options.scenario))
scenario = await import(path.resolve(process.cwd(), options.scenario))
}

console.log('\n' + `
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export async function * findLeaks (pageUrl, options = {}) {

const runIteration = async (test, i, numTests) => {
try {
const prefix = `Test ${i + 1}/${numTests} - ${test.description} -`
const prefix = `Test ${i + 1}/${numTests}${test.description ? ` - ${test.description}` : ''} -`
return (await runWithSpinner(progress, async (onProgress) => {
const onProgressWithPrefix = message => {
onProgress(`${prefix} ${message}`)
Expand Down

0 comments on commit 00e9202

Please sign in to comment.