Skip to content

Commit

Permalink
fix tests on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
75lb committed Aug 23, 2024
1 parent 3f5980c commit 1cdad7b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 21 deletions.
5 changes: 3 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import TestRunner from 'test-runner'
import path from 'path'
import Test from './test.js'
import ansi from 'ansi-escape-sequences'
import { pathToFileURL } from 'node:url'

class Cli {
async start (argv) {
Expand All @@ -19,7 +19,8 @@ class Cli {
}

for (const file of config.files) {
const testModule = await import(path.resolve(file))
const importPath = pathToFileURL(file).href
const testModule = await import(importPath)
if (!testModule) {
throw new Error(`File did not export any tests: ${file}`)
}
Expand Down
12 changes: 1 addition & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"envs": []
},
"dependencies": {
"ansi-escape-sequences": "^6.2.2",
"current-module-paths": "^1.1.1"
"ansi-escape-sequences": "^6.2.2"
}
}
7 changes: 1 addition & 6 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import TestRunner from 'test-runner'
import Test from '../lib/test.js'
import Cli from '../lib/cli.js'
import { strict as a } from 'assert'
import path from 'node:path'
import currentModulePaths from 'current-module-paths'

const { __dirname } = currentModulePaths(import.meta.url)

/* Node.js version 12 compatible - no module-level await. */

Expand All @@ -25,8 +21,7 @@ one()

/* Cli loads and runs a test file */
async function cli () {
const actuals = []
const cli = new Cli()
const runner = await cli.start([path.resolve(__dirname, 'fixture', 'one.js')])
await cli.start(['./test/fixture/one.js'])
}
cli()

0 comments on commit 1cdad7b

Please sign in to comment.