@exodus/test 1.0.0-rc.66 → 1.0.0-rc.68

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/bin/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { spawn, execFile as execFileCallback } from 'node:child_process'
3
+ import { spawn, spawnSync, execFile as execFileCallback } from 'node:child_process'
4
4
  import { promisify } from 'node:util'
5
5
  import { once } from 'node:events'
6
6
  import { fileURLToPath } from 'node:url'
@@ -89,6 +89,14 @@ function parseOptions() {
89
89
  const pathsEqual = (a, b) => a === b || (existsSync(a) && realpathSync(a) === b) // resolve symlinks
90
90
  assert(basename(jsname) === 'exodus-test' || pathsEqual(jsname, fileURLToPath(import.meta.url)))
91
91
 
92
+ if (args[0] === '--playwright') {
93
+ const playwright = dirname(fileURLToPath(import.meta.resolve('playwright-core/package.json')))
94
+ const cli = resolve(playwright, 'cli.js')
95
+ const res = spawnSync(cli, args.slice(1), { stdio: 'inherit' })
96
+ process.exitCode = res.status ?? 1
97
+ process.exit(0)
98
+ }
99
+
92
100
  while (args[0]?.startsWith('-')) {
93
101
  const option = args.shift()
94
102
  if (option.includes('=')) {
package/bundler/bundle.js CHANGED
@@ -279,6 +279,7 @@ export const build = async (...files) => {
279
279
  'tape-promise/tape': resolveImport('../src/tape.cjs'),
280
280
  'node:test': resolveImport('../src/node.js'),
281
281
  // Inner
282
+ 'exodus-test:text-encoding-utf': api('text-encoding-utf.cjs'),
282
283
  'exodus-test:util-format': api('util-format.cjs'),
283
284
  // Node.js (except node:test)
284
285
  ...Object.fromEntries(Object.entries(nodeUnprefixed).map(([k, v]) => [`node:${k}`, v])),
@@ -200,7 +200,7 @@ if (
200
200
  ) {
201
201
  if (!globalThis.URLSearchParams) globalThis.URLSearchParams = require('@ungap/url-search-params')
202
202
  if (!globalThis.TextEncoder || !globalThis.TextDecoder) {
203
- const { TextEncoder, TextDecoder } = require('text-encoding')
203
+ const { TextEncoder, TextDecoder } = require('exodus-test:text-encoding-utf')
204
204
  if (!globalThis.TextEncoder) globalThis.TextEncoder = TextEncoder
205
205
  if (!globalThis.TextDecoder) global.TextDecoder = TextDecoder
206
206
  }
@@ -0,0 +1,77 @@
1
+ // Adapted from https://github.com/ExodusMovement/text-encoding-utf8
2
+
3
+ /* eslint-disable unicorn/prefer-set-has, unicorn/text-encoding-identifier-case */
4
+
5
+ const UTF8 = 'utf-8'
6
+ const UTF16LE = 'utf-16le'
7
+
8
+ // https://encoding.spec.whatwg.org/#names-and-labels
9
+ const UTF8alias = ['utf8', 'unicode-1-1-utf-8', 'unicode11utf8', 'unicode20utf8', 'x-unicode20utf8']
10
+ const UTF16LEalias = ['utf-16', 'ucs-2', 'unicode', 'unicodefeff', 'iso-10646-ucs-2', 'csunicode'] // but not utf16
11
+
12
+ const normalizeEncoding = (encoding) => {
13
+ const lower = encoding.toLowerCase()
14
+ if (UTF8 === lower || UTF16LE === lower) return lower // fast path
15
+ if (UTF8alias.includes(lower)) return UTF8
16
+ if (UTF16LEalias.includes(lower)) return UTF16LE
17
+ return lower
18
+ }
19
+
20
+ const defineFinal = (obj, key, value) => Object.defineProperty(obj, key, { value, writable: false })
21
+
22
+ const assertUTF8 = (encoding) => {
23
+ if (encoding !== UTF8) throw new Error('only utf-8 is supported')
24
+ }
25
+
26
+ const assertUTF8orUTF16LE = (enc) => {
27
+ // We don't include ascii because it's an alias to windows-1252 in TextDecoder and differs from Buffer ascii
28
+ // We don't include utf-16be because it's not supported by buffer package
29
+ if (enc !== UTF8 && enc !== UTF16LE) throw new Error('only utf-8 and utf-16le are supported')
30
+ }
31
+
32
+ const assertBufferSource = (buf) => {
33
+ if (buf instanceof ArrayBuffer || ArrayBuffer.isView(buf)) return
34
+ if (globalThis.SharedArrayBuffer && buf instanceof globalThis.SharedArrayBuffer) return
35
+ throw new Error('argument must be a SharedArrayBuffer, ArrayBuffer or ArrayBufferView')
36
+ }
37
+
38
+ // encoding argument is non-standard but catches usage of 'text-encoding' npm package API
39
+ // Standard TextEncoder constructor doesn't have any arguments at all and is always utf-8
40
+ function TextEncoder(encoding = UTF8) {
41
+ encoding = normalizeEncoding(encoding)
42
+ assertUTF8(encoding)
43
+ defineFinal(this, 'encoding', encoding)
44
+ }
45
+
46
+ TextEncoder.prototype.encode = function (str) {
47
+ const buf = Buffer.from(str)
48
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.length)
49
+ }
50
+
51
+ TextEncoder.prototype.encodeInto = function () {
52
+ throw new Error('not supported')
53
+ }
54
+
55
+ function TextDecoder(encoding = UTF8, options = {}) {
56
+ encoding = normalizeEncoding(encoding)
57
+ assertUTF8orUTF16LE(encoding)
58
+
59
+ const { fatal = true, ignoreBOM = false, stream = false } = options
60
+ if (fatal !== true) throw new Error('disabling "fatal" mode is not supported')
61
+ if (ignoreBOM !== false) throw new Error('option "ignoreBOM" is not supported')
62
+ if (stream !== false) throw new Error('option "stream" is not supported')
63
+
64
+ // see: https://github.com/inexorabletash/text-encoding/blob/master/lib/encoding.js#L1049
65
+ defineFinal(this, 'encoding', encoding)
66
+ defineFinal(this, 'fatal', fatal)
67
+ defineFinal(this, 'ignoreBOM', ignoreBOM)
68
+ }
69
+
70
+ TextDecoder.prototype.decode = function (buf) {
71
+ if (buf === undefined) return ''
72
+ assertBufferSource(buf)
73
+ if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf)
74
+ return buf.toString(this.encoding)
75
+ }
76
+
77
+ module.exports = { TextEncoder, TextDecoder }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/test",
3
- "version": "1.0.0-rc.66",
3
+ "version": "1.0.0-rc.68",
4
4
  "author": "Exodus Movement, Inc.",
5
5
  "description": "A test suite runner",
6
6
  "homepage": "https://github.com/ExodusMovement/test",
@@ -59,6 +59,7 @@
59
59
  "bundler/modules/jest-message-util.js",
60
60
  "bundler/modules/jest-util.js",
61
61
  "bundler/modules/node-buffer.cjs",
62
+ "bundler/modules/text-encoding-utf.cjs",
62
63
  "bundler/modules/url.cjs",
63
64
  "bundler/modules/util-format.cjs",
64
65
  "bundler/modules/ws.cjs",
@@ -138,7 +139,7 @@
138
139
  "c8": "^9.1.0",
139
140
  "constants-browserify": "^1.0.0",
140
141
  "crypto-browserify": "^3.12.0",
141
- "esbuild": "~0.23.1",
142
+ "esbuild": "~0.25.2",
142
143
  "events": "^3.3.0",
143
144
  "expect": "^29.7.0",
144
145
  "fast-glob": "^3.2.11",
@@ -152,9 +153,8 @@
152
153
  "puppeteer-core": "^24.6.0",
153
154
  "querystring-es3": "^0.2.1",
154
155
  "stream-browserify": "^3.0.0",
155
- "text-encoding": "^0.7.0",
156
156
  "timers-browserify": "^2.0.12",
157
- "tsx": "^4.19.0",
157
+ "tsx": "^4.19.3",
158
158
  "url": "^0.11.0",
159
159
  "util": "^0.12.5"
160
160
  },
@@ -16,9 +16,7 @@ let willstart
16
16
  const abstractProcess = globalThis.process || globalThis.EXODUS_TEST_PROCESS
17
17
 
18
18
  if (process.env.EXODUS_TEST_IS_BROWSER) {
19
- let promise
20
- globalThis.EXODUS_TEST_PROMISE = new Promise((resolve, reject) => (promise = { resolve, reject }))
21
- abstractProcess._exitHook = (exitCode) => promise.resolve(exitCode)
19
+ globalThis.EXODUS_TEST_PROMISE = new Promise((resolve) => (abstractProcess._exitHook = resolve))
22
20
  }
23
21
 
24
22
  // assert module is slower
@@ -147,7 +145,7 @@ async function runContext(context) {
147
145
  for (const c of stack) await c.runHooks('afterEach', context)
148
146
 
149
147
  const status = error === undefined ? '✔ PASS' : '✖ FAIL'
150
- print(status, context.fullName, options.todo ? '# TODO' : '')
148
+ print(status, context.fullName, ...(options.todo ? ['# TODO'] : []))
151
149
  if (error) {
152
150
  delete error.matcherResult
153
151
  print(' ', error)