qunitx 1.0.1 → 1.0.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "qunitx",
3
3
  "type": "module",
4
- "version": "1.0.1",
4
+ "version": "1.0.3",
5
5
  "description": "A universal test framework for testing any js file on node.js, browser or deno with QUnit API",
6
6
  "author": "Izel Nakri",
7
7
  "license": "MIT",
@@ -83,6 +83,9 @@
83
83
  "test:node": "node --test test/index.js",
84
84
  "coverage": "deno test --coverage=tmp/coverage --allow-read --allow-env --allow-run test/index.js && deno coverage --lcov --output=tmp/coverage/lcov.info --include='shims/' tmp/coverage && node scripts/check-coverage.js",
85
85
  "coverage:report": "npm run coverage && deno coverage --html --include='shims/' tmp/coverage",
86
+ "bench": "deno task bench",
87
+ "bench:check": "deno task bench:check",
88
+ "bench:update": "deno task bench:update",
86
89
  "docs": "deno doc --html --name=\"QUnitX\" --output=docs/src shims/deno/index.js"
87
90
  },
88
91
  "devDependencies": {
@@ -64,8 +64,8 @@ export default function module(moduleName, runtimeOptions, moduleContent) {
64
64
  }
65
65
  });
66
66
  afterAll(async () => {
67
- for (const assert of moduleContext.tests.map(testContext => testContext.assert)) {
68
- await assert.waitForAsyncOps();
67
+ for (const testContext of moduleContext.tests) {
68
+ await testContext.assert.waitForAsyncOps();
69
69
  }
70
70
 
71
71
  const targetContext = moduleContext.tests[moduleContext.tests.length - 1];
@@ -37,8 +37,8 @@ export default function module(moduleName, runtimeOptions, moduleContent) {
37
37
  }
38
38
  });
39
39
  afterAll(async () => {
40
- for (const assert of moduleContext.tests.map(testContext => testContext.assert)) {
41
- await assert.waitForAsyncOps();
40
+ for (const testContext of moduleContext.tests) {
41
+ await testContext.assert.waitForAsyncOps();
42
42
  }
43
43
 
44
44
  const targetContext = moduleContext.tests[moduleContext.tests.length - 1];
@@ -1,9 +1,5 @@
1
1
  const hasOwn = Object.prototype.hasOwnProperty
2
2
 
3
- const _typeof = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol'
4
- ? (obj) => typeof obj
5
- : (obj) => obj && typeof Symbol === 'function' && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj;
6
-
7
3
  export function objectType(obj) {
8
4
  if (typeof obj === 'undefined') {
9
5
  return 'undefined';
@@ -13,8 +9,8 @@ export function objectType(obj) {
13
9
  if (obj === null) {
14
10
  return 'null';
15
11
  }
16
- const match = toString.call(obj).match(/^\[object\s(.*)\]$/);
17
- const type = match && match[1];
12
+ // slice(8, -1) extracts the type name from "[object Foo]" without a regex
13
+ const type = toString.call(obj).slice(8, -1);
18
14
  switch (type) {
19
15
  case 'Number':
20
16
  if (isNaN(obj)) {
@@ -32,7 +28,7 @@ export function objectType(obj) {
32
28
  case 'Symbol':
33
29
  return type.toLowerCase();
34
30
  default:
35
- return _typeof(obj);
31
+ return typeof obj;
36
32
  }
37
33
  }
38
34
 
@@ -40,8 +36,7 @@ function is(type, obj) {
40
36
  return objectType(obj) === type;
41
37
  }
42
38
 
43
- export function objectValues(obj) {
44
- const allowArray = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
39
+ export function objectValues(obj, allowArray = true) {
45
40
  const vals = allowArray && is('array', obj) ? [] : {};
46
41
 
47
42
  for (const key in obj) {
@@ -1,15 +0,0 @@
1
- import { readFile } from 'node:fs/promises';
2
-
3
- const THRESHOLD = 85;
4
- const lcov = await readFile('tmp/coverage/lcov.info', 'utf8');
5
-
6
- const lh = [...lcov.matchAll(/^LH:(\d+)/gm)].reduce((s, m) => s + parseInt(m[1]), 0);
7
- const lf = [...lcov.matchAll(/^LF:(\d+)/gm)].reduce((s, m) => s + parseInt(m[1]), 0);
8
- const pct = lf > 0 ? (lh / lf) * 100 : 0;
9
-
10
- console.log(`Coverage: ${pct.toFixed(1)}% (${lh}/${lf} lines)`);
11
-
12
- if (pct < THRESHOLD) {
13
- console.error(`Error: coverage ${pct.toFixed(1)}% is below the ${THRESHOLD}% threshold.`);
14
- process.exit(1);
15
- }