beartest-js 7.1.1 → 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/main.yml +10 -6
- package/beartest.js +5 -4
- package/cli.js +9 -9
- package/package.json +4 -5
- package/index.js +0 -1
- /package/{index.d.ts → beartest.d.ts} +0 -0
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
name: Node.js Package
|
|
2
|
+
permissions:
|
|
3
|
+
id-token: write # Required for OIDC
|
|
4
|
+
contents: read
|
|
2
5
|
on:
|
|
3
6
|
push:
|
|
4
7
|
branches:
|
|
@@ -11,9 +14,10 @@ jobs:
|
|
|
11
14
|
# Setup .npmrc file to publish to npm
|
|
12
15
|
- uses: actions/setup-node@v1
|
|
13
16
|
with:
|
|
14
|
-
node-version:
|
|
15
|
-
registry-url:
|
|
16
|
-
|
|
17
|
-
- run:
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
node-version: "22.x"
|
|
18
|
+
registry-url: "https://registry.npmjs.org"
|
|
19
|
+
|
|
20
|
+
- run: "npm install -g npm@^11.0.0"
|
|
21
|
+
- run: "npm --version"
|
|
22
|
+
- run: npm install
|
|
23
|
+
- run: npm publish ./
|
package/beartest.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
|
|
2
3
|
async function RunSerially(fnArray) {
|
|
3
4
|
for (const fn of fnArray) await fn()
|
|
4
5
|
}
|
|
@@ -83,7 +84,7 @@ const beforeEach = (fn) => top().beforeEach.push(fn)
|
|
|
83
84
|
const after = (fn) => top().after.push(fn)
|
|
84
85
|
const afterEach = (fn) => top().afterEach.push(fn)
|
|
85
86
|
|
|
86
|
-
async function*
|
|
87
|
+
export async function* run(options = {}) {
|
|
87
88
|
let index = 0
|
|
88
89
|
for await (const file of options.files) {
|
|
89
90
|
const name = file
|
|
@@ -91,7 +92,7 @@ async function* runTests(options = {}) {
|
|
|
91
92
|
suiteStack.push({ before: [], beforeEach: [], after: [], afterEach: [], tests: [], name })
|
|
92
93
|
let suiteStart
|
|
93
94
|
try {
|
|
94
|
-
|
|
95
|
+
await import(file)
|
|
95
96
|
yield { type: 'test:start', data: { name: name, nesting: 0, type: 'suite' } }
|
|
96
97
|
suiteStart = Date.now()
|
|
97
98
|
for await (let event of runTestSuite({ only: options.only })) {
|
|
@@ -141,4 +142,4 @@ if (!suiteStack.length) {
|
|
|
141
142
|
})
|
|
142
143
|
}
|
|
143
144
|
|
|
144
|
-
|
|
145
|
+
export const test = Object.assign(it, { describe, before, beforeEach, after, afterEach })
|
package/cli.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { run } from './beartest'
|
|
4
|
+
import { promises } from 'node:fs'
|
|
5
|
+
import { sep, resolve, isAbsolute, parse, relative } from 'node:path'
|
|
6
6
|
|
|
7
7
|
const INCLUDE = ['**/*.{test,spec}.{js,ts,jsx,tsx}']
|
|
8
8
|
const EXCLUDE = ['**/node_modules/**', '**/dist/**', '**/.git/**', '**/build/**', '**/coverage/**']
|
|
9
9
|
|
|
10
10
|
const hasGlob = (s) => /[*?\[\]{}()!]/.test(s)
|
|
11
|
-
const norm = (p) => p.split(
|
|
11
|
+
const norm = (p) => p.split(sep).join('/')
|
|
12
12
|
|
|
13
13
|
async function discoverAll() {
|
|
14
14
|
const seen = new Set()
|
|
15
15
|
for (const pat of INCLUDE) {
|
|
16
|
-
for await (const f of
|
|
16
|
+
for await (const f of promises.glob(pat, { ignore: EXCLUDE })) seen.add(norm(f))
|
|
17
17
|
}
|
|
18
18
|
return [...seen].sort()
|
|
19
19
|
}
|
|
@@ -25,7 +25,7 @@ async function applyFilters(files, args) {
|
|
|
25
25
|
for (const arg of args) {
|
|
26
26
|
if (hasGlob(arg)) {
|
|
27
27
|
const gset = new Set()
|
|
28
|
-
for await (const f of
|
|
28
|
+
for await (const f of promises.glob(arg, { ignore: EXCLUDE })) gset.add(norm(f))
|
|
29
29
|
out = out.filter((f) => gset.has(f)) // glob filter
|
|
30
30
|
} else {
|
|
31
31
|
const needle = norm(arg)
|
|
@@ -39,11 +39,11 @@ async function cli() {
|
|
|
39
39
|
const discovered = await discoverAll()
|
|
40
40
|
const selected = await applyFilters(discovered, process.argv.slice(2))
|
|
41
41
|
|
|
42
|
-
for await (let event of run({ files: selected.map((f) =>
|
|
42
|
+
for await (let event of run({ files: selected.map((f) => resolve(f)) })) {
|
|
43
43
|
const prefix = ' '.repeat(event.data.nesting)
|
|
44
44
|
if (event.type === 'test:start' && event.data.type === 'suite') {
|
|
45
|
-
if (
|
|
46
|
-
console.log(`\x1b[36m${prefix}${
|
|
45
|
+
if (isAbsolute(event.data.name)) {
|
|
46
|
+
console.log(`\x1b[36m${prefix}${parse(event.data.name).name} (${relative('./', event.data.name)})\x1b[0m`)
|
|
47
47
|
} else {
|
|
48
48
|
console.log(`\x1b[36m${prefix}${event.data.name}\x1b[0m`)
|
|
49
49
|
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "beartest-js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.1",
|
|
4
4
|
"description": "Bear Bones Testing",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/rubber-duck-software/beartest.git"
|
|
8
8
|
},
|
|
9
|
-
"types": "./index.d.ts",
|
|
10
9
|
"main": "./index.js",
|
|
10
|
+
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"
|
|
14
|
-
"
|
|
13
|
+
"default": "./beartest.js",
|
|
14
|
+
"types": "./beartest.d.ts"
|
|
15
15
|
},
|
|
16
16
|
"./package.json": "./package.json"
|
|
17
17
|
},
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
},
|
|
21
21
|
"author": "Grant Colestock",
|
|
22
22
|
"license": "MIT",
|
|
23
|
-
"type": "commonjs",
|
|
24
23
|
"bugs": {
|
|
25
24
|
"url": "https://github.com/rubber-duck-software/beartest/issues"
|
|
26
25
|
},
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require("./beartest");
|
|
File without changes
|