itee-validators 5.6.0 → 6.0.0

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.
Files changed (131) hide show
  1. package/.github/workflows/node.js.yml +2 -2
  2. package/.releaserc.mjs +94 -0
  3. package/.tasks/.builds/build-benchmarks.task.mjs +16 -0
  4. package/.tasks/.builds/build-tests.task.mjs +18 -0
  5. package/.tasks/.builds/build-unit-tests.task.mjs +16 -0
  6. package/.tasks/.builds/build.task.mjs +46 -0
  7. package/.tasks/.cleans/clean.task.mjs +23 -0
  8. package/.tasks/.docs/doc.task.mjs +35 -0
  9. package/.tasks/.helps/help.task.mjs +151 -0
  10. package/.tasks/.lints/lint.task.mjs +37 -0
  11. package/.tasks/.patches/patch.task.mjs +13 -0
  12. package/.tasks/.releases/release.task.mjs +26 -0
  13. package/.tasks/.tests/benchmarks/build-benchmarks-backend.task.mjs +42 -0
  14. package/.tasks/{tests/benchmarks/compute-benchmarks.mjs → .tests/benchmarks/compute-benchmarks.task.mjs} +46 -51
  15. package/.tasks/.tests/benchmarks/run-benchmarks-for-backend.task.mjs +39 -0
  16. package/.tasks/.tests/benchmarks/run-benchmarks-for-frontend.task.mjs +41 -0
  17. package/.tasks/.tests/benchmarks/run-benchmarks.task.mjs +18 -0
  18. package/.tasks/{tests/bundling/check-bundling-from-esm-build-import.mjs → .tests/bundling/check-bundling-from-esm-build-import.task.mjs} +31 -75
  19. package/.tasks/.tests/bundling/check-bundling-from-esm-files-direct.task.mjs +77 -0
  20. package/.tasks/.tests/bundling/check-bundling-from-esm-files-import.task.mjs +95 -0
  21. package/.tasks/.tests/bundling/check-bundling.task.mjs +20 -0
  22. package/.tasks/.tests/run-tests.task.mjs +18 -0
  23. package/.tasks/.tests/unit-tests/build-unit-tests-backend.task.mjs +42 -0
  24. package/.tasks/{tests/unit-tests/compute-unit-tests.mjs → .tests/unit-tests/compute-unit-tests.task.mjs} +152 -193
  25. package/.tasks/.tests/unit-tests/run-unit-tests-for-backend.task.mjs +44 -0
  26. package/.tasks/.tests/unit-tests/run-unit-tests-for-frontend.task.mjs +41 -0
  27. package/.tasks/.tests/unit-tests/run-unit-tests.task.mjs +18 -0
  28. package/.tasks/_refresh-gulpfile.task.mjs +65 -0
  29. package/.tasks/_utils.mjs +159 -33
  30. package/.tasks/configs/benchmarks.conf.mjs +57 -0
  31. package/.tasks/configs/build-benchmarks-backend.conf.mjs +51 -0
  32. package/.tasks/configs/build-unit-tests-backend.conf.mjs +46 -0
  33. package/.tasks/configs/build.conf.mjs +354 -0
  34. package/.tasks/configs/check-bundling.conf.mjs +26 -0
  35. package/.tasks/configs/clean.conf.mjs +9 -0
  36. package/.tasks/configs/compute-benchmarks.conf.mjs +28 -0
  37. package/.tasks/configs/compute-unit-tests.conf.mjs +27 -0
  38. package/.tasks/configs/doc.conf.json +50 -0
  39. package/.tasks/configs/eslint.conf.mjs +121 -0
  40. package/.tasks/configs/units.conf.mjs +27 -0
  41. package/.tasks/itee-benchmarks-framework.js +186 -0
  42. package/.tasks/itee-reporter.mjs +217 -0
  43. package/CHANGELOG.md +12 -0
  44. package/builds/itee-validators.cjs.js +53 -15
  45. package/builds/itee-validators.cjs.js.map +1 -1
  46. package/builds/itee-validators.cjs.min.js +36 -35
  47. package/builds/itee-validators.esm.js +25 -2
  48. package/builds/itee-validators.esm.js.map +1 -1
  49. package/builds/itee-validators.esm.min.js +3 -3
  50. package/builds/itee-validators.iife.js +25 -4
  51. package/builds/itee-validators.iife.js.map +1 -1
  52. package/builds/itee-validators.iife.min.js +10 -10
  53. package/package.json +49 -41
  54. package/sources/cores/_cores.js +10 -10
  55. package/sources/cores/arrays/_arrays.js +12 -12
  56. package/sources/cores/arrays/isArrayOfArray.js +2 -2
  57. package/sources/cores/arrays/isArrayOfBoolean.js +3 -3
  58. package/sources/cores/arrays/isArrayOfFunction.js +3 -3
  59. package/sources/cores/arrays/isArrayOfMultiElement.js +1 -1
  60. package/sources/cores/arrays/isArrayOfNull.js +3 -3
  61. package/sources/cores/arrays/isArrayOfNumber.js +3 -3
  62. package/sources/cores/arrays/isArrayOfObject.js +3 -3
  63. package/sources/cores/arrays/isArrayOfSingleElement.js +1 -1
  64. package/sources/cores/arrays/isArrayOfString.js +3 -3
  65. package/sources/cores/arrays/isArrayOfUndefined.js +3 -3
  66. package/sources/cores/arrays/isEmptyArray.js +1 -1
  67. package/sources/cores/booleans/_booleans.js +2 -2
  68. package/sources/cores/booleans/isTrue.js +1 -1
  69. package/sources/cores/cores.js +8 -8
  70. package/sources/cores/functions/_functions.js +1 -1
  71. package/sources/cores/numbers/_numbers.js +6 -6
  72. package/sources/cores/numbers/isNumber.js +3 -3
  73. package/sources/cores/objects/_objects.js +2 -2
  74. package/sources/cores/objects/isEmptyObject.js +1 -1
  75. package/sources/cores/objects/isObject.js +1 -1
  76. package/sources/cores/strings/_strings.js +3 -3
  77. package/sources/cores/strings/isBlankString.js +2 -2
  78. package/sources/cores/strings/isEmptyString.js +1 -1
  79. package/sources/cores/symbols/_symbols.js +1 -1
  80. package/sources/cores/tests/isTestUnitGenerator.js +5 -6
  81. package/sources/cores/typed-arrays/_typedArrays.js +12 -12
  82. package/sources/cores/voids/_voids.js +4 -4
  83. package/sources/cores/voids/isEmpty.js +4 -4
  84. package/sources/file-system/_file-system.js +9 -9
  85. package/sources/file-system/block-devices/_blockDevices.js +3 -3
  86. package/sources/file-system/block-devices/isBlockDevicePath.js +3 -3
  87. package/sources/file-system/block-devices/isValidBlockDevicePath.js +2 -2
  88. package/sources/file-system/character-devices/_characterDevices.js +3 -3
  89. package/sources/file-system/character-devices/isCharacterDevicePath.js +3 -3
  90. package/sources/file-system/character-devices/isValidCharacterDevicePath.js +2 -2
  91. package/sources/file-system/directories/_directories.js +4 -4
  92. package/sources/file-system/directories/isDirectoryPath.js +3 -3
  93. package/sources/file-system/directories/isEmptyDirectory.js +2 -2
  94. package/sources/file-system/directories/isValidDirectoryPath.js +2 -2
  95. package/sources/file-system/fifo-pipes/_fifoPipes.js +3 -3
  96. package/sources/file-system/fifo-pipes/isFIFOPath.js +3 -3
  97. package/sources/file-system/fifo-pipes/isValidFIFOPath.js +2 -2
  98. package/sources/file-system/files/_files.js +4 -4
  99. package/sources/file-system/files/isEmptyFile.js +3 -3
  100. package/sources/file-system/files/isFilePath.js +3 -3
  101. package/sources/file-system/files/isValidFilePath.js +2 -2
  102. package/sources/file-system/paths/_paths.js +2 -2
  103. package/sources/file-system/paths/isValidPath.js +1 -1
  104. package/sources/file-system/sockets/_sockets.js +3 -3
  105. package/sources/file-system/sockets/isSocketPath.js +3 -3
  106. package/sources/file-system/sockets/isValidSocketPath.js +2 -2
  107. package/sources/file-system/symbolic-links/_symbolicLinks.js +3 -3
  108. package/sources/file-system/symbolic-links/isSymbolicLinkPath.js +3 -3
  109. package/sources/file-system/symbolic-links/isValidSymbolicLinkPath.js +2 -2
  110. package/sources/itee-validators.js +4 -4
  111. package/sources/maths/_maths.js +1 -1
  112. package/sources/physics/_physics.js +2 -2
  113. package/sources/physics/temperatures/_temperatures.js +5 -5
  114. package/sources/physics/temperatures/isCelsius.js +2 -2
  115. package/sources/physics/temperatures/isFahrenheit.js +2 -2
  116. package/sources/physics/temperatures/isKelvin.js +2 -2
  117. package/sources/physics/temperatures/isTemperature.js +3 -3
  118. package/.tasks/builds/build.mjs +0 -65
  119. package/.tasks/cleans/clean.mjs +0 -20
  120. package/.tasks/docs/doc.mjs +0 -37
  121. package/.tasks/helps/help.mjs +0 -195
  122. package/.tasks/lints/lint.mjs +0 -33
  123. package/.tasks/patches/patch.mjs +0 -9
  124. package/.tasks/tests/benchmarks/bundle-benchmarks.mjs +0 -33
  125. package/.tasks/tests/benchmarks/run-benchmarks-for-backend.mjs +0 -24
  126. package/.tasks/tests/benchmarks/run-benchmarks-for-frontend.mjs +0 -38
  127. package/.tasks/tests/bundling/check-bundling-from-esm-files-direct.mjs +0 -129
  128. package/.tasks/tests/bundling/check-bundling-from-esm-files-import.mjs +0 -149
  129. package/.tasks/tests/unit-tests/bundle-unit-tests.mjs +0 -33
  130. package/.tasks/tests/unit-tests/run-unit-tests-for-backend.mjs +0 -25
  131. package/.tasks/tests/unit-tests/run-unit-tests-for-frontend.mjs +0 -41
@@ -0,0 +1,186 @@
1
+ import {
2
+ getConfig,
3
+ sessionFailed,
4
+ sessionFinished,
5
+ sessionStarted,
6
+ } from '@web/test-runner-core/browser/session.js'
7
+
8
+ ///////
9
+
10
+ class TestResultError {
11
+
12
+ /**
13
+ * @param {string} message
14
+ * @param {string|null} name
15
+ * @param {string|null} stack
16
+ * @param {string|null} expected
17
+ * @param {string|null} actual
18
+ */
19
+ constructor(
20
+ message,
21
+ name = null,
22
+ stack = null,
23
+ expected = null,
24
+ actual = null,
25
+ ) {
26
+ this.message = message
27
+ this.name = name
28
+ this.stack = stack
29
+ this.expected = expected
30
+ this.actual = actual
31
+ }
32
+
33
+ }
34
+
35
+ class TestSuiteResult {
36
+
37
+ /**
38
+ *
39
+ * @param {string} name
40
+ * @param {Array.<TestSuiteResult>} suites
41
+ * @param {Array.<TestResult>} tests
42
+ */
43
+ constructor( name, suites = [], tests = [] ) {
44
+ this.name = name
45
+ this.suites = suites
46
+ this.tests = tests
47
+ }
48
+
49
+ }
50
+
51
+ class TestResult {
52
+
53
+ /**
54
+ * @param {string} name
55
+ * @param {boolean} passed
56
+ * @param {boolean} skipped
57
+ * @param {number|null} duration
58
+ * @param {TestResultError|null} error
59
+ */
60
+ constructor( name, passed, skipped = false, duration = null, error = null, stats = null ) {
61
+ this.name = name
62
+ this.passed = passed
63
+ this.skipped = skipped
64
+ this.duration = duration
65
+ this.error = error
66
+ this.stats = stats
67
+ }
68
+
69
+ }
70
+
71
+ class TestSession {
72
+
73
+ // BasicTestSession //
74
+ // id: string;
75
+ // group: TestSessionGroup;
76
+ // browser: BrowserLauncher;
77
+ // testFile: string;
78
+
79
+ // TestSession //
80
+ // debug: false;
81
+ // testRun: number;
82
+ // status: TestSessionStatus;
83
+ // passed?: boolean;
84
+ // errors: TestResultError[];
85
+ // testResults?: TestSuiteResult;
86
+ // logs: any[][];
87
+ // request404s: string[];
88
+ // testCoverage?: CoverageMapData;
89
+
90
+ /**
91
+ * @param {boolean|null} passed
92
+ * @param {Array.<TestResultError>} errors
93
+ * @param {TestSuiteResult|null} testResults
94
+ */
95
+ constructor( passed, errors = [], testResults = null ) {
96
+ this.passed = passed
97
+ this.errors = errors
98
+ this.testResults = testResults
99
+ }
100
+
101
+ }
102
+
103
+ ///////
104
+
105
+ async function runTests( testData ) {
106
+
107
+ let suiteResults = []
108
+ for ( const exportKey in testData ) {
109
+ const suite = testData[ exportKey ]
110
+ const suiteResult = await new Promise( ( resolve ) => {
111
+
112
+ // suite.on( 'start', event => console.log )
113
+ // suite.on( 'cycle', event => console.log )
114
+
115
+ suite.on( 'complete', ( event ) => {
116
+ // console.log(event.currentTarget)
117
+ const testResults = event.currentTarget.map( target => new TestResult( target.name, true, false, target.hz, undefined, target.times ) )
118
+ const suiteResult = new TestSuiteResult( suite.name, undefined, testResults )
119
+
120
+ resolve( suiteResult )
121
+ } )
122
+
123
+ suite.run()
124
+
125
+ } )
126
+
127
+ suiteResults.push( suiteResult )
128
+ }
129
+
130
+ return {
131
+ name: 'Benchmark',
132
+ suites: suiteResults, // TestSuiteResult
133
+ tests: [], // TestResult
134
+ passed: true
135
+ }
136
+
137
+ }
138
+
139
+ ( async () => {
140
+ // notify the test runner that we're alive
141
+ await sessionStarted()
142
+
143
+ // fetch the config for this test run, this will tell you which file we're testing
144
+ const {
145
+ testFile,
146
+ watch,
147
+ debug,
148
+ testFrameworkConfig
149
+ } = await getConfig()
150
+
151
+ // load the test file as an es module
152
+ const failedImports = []
153
+ let testData = null
154
+ try {
155
+ const testFileURL = new URL( testFile, document.baseURI )
156
+ testData = await import(testFileURL.href)
157
+ } catch ( error ) {
158
+ failedImports.push( {
159
+ file: testFile,
160
+ error: {
161
+ message: error.message,
162
+ stack: error.stack
163
+ }
164
+ } )
165
+ }
166
+
167
+ try {
168
+ // run the actual tests, this is what you need to implement
169
+ const testResults = await runTests( testData )
170
+ // console.log( 'After runTests, testResults:', testResults )
171
+ const passed = failedImports.length === 0 && testResults.passed
172
+ const sessionResult = new TestSession( passed, failedImports, testResults )
173
+
174
+ // notify tests run finished
175
+ await sessionFinished( sessionResult )
176
+ } catch ( error ) {
177
+ // notify an error occurred
178
+ const sessionError = new TestResultError(
179
+ error.message,
180
+ error.name,
181
+ error.stack
182
+ )
183
+ await sessionFailed( sessionError )
184
+ }
185
+
186
+ } )()
@@ -0,0 +1,217 @@
1
+ import { SESSION_STATUS } from '@web/test-runner'
2
+ import colors from 'ansi-colors'
3
+ import {
4
+ existsSync,
5
+ mkdirSync,
6
+ writeFileSync
7
+ } from 'node:fs'
8
+ import {
9
+ dirname,
10
+ relative,
11
+ resolve
12
+ } from 'node:path'
13
+
14
+ const yellow = colors.yellow
15
+ const green = colors.green
16
+
17
+ export function iteeReporter( {
18
+ reportResults = true,
19
+ reportProgress = true,
20
+ outputFilePath = '.reports/web_test_runner_report.json'
21
+ } = {} ) {
22
+
23
+ const _reportResults = reportResults
24
+ const _reportProgress = reportProgress
25
+ const _reportFilePath = resolve( outputFilePath )
26
+ const _report = {
27
+ config: {},
28
+ sessions: {},
29
+ testCoverage: {},
30
+ testFiles: [],
31
+ browserNames: [],
32
+ focusedTestFile: null,
33
+ startTime: null,
34
+ endTime: null,
35
+ }
36
+ let _logger = null
37
+ let _debug = null
38
+
39
+ return {
40
+ /**
41
+ * Called once when the test runner starts.
42
+ */
43
+ start( {
44
+ config,
45
+ browserNames,
46
+ testFiles,
47
+ startTime
48
+ } ) {
49
+ _logger = config.logger
50
+ _debug = config.debug
51
+
52
+ _report.config = {
53
+ browsers: config.browsers.map( browser => ( {
54
+ name: browser.name,
55
+ type: browser.type,
56
+ concurrency: browser.concurrency,
57
+ } ) ),
58
+ browserLogs: config.browserLogs,
59
+ browserStartTimeout: config.browserStartTimeout,
60
+ concurrency: config.concurrency,
61
+ concurrentBrowsers: config.concurrentBrowsers,
62
+ coverage: config.coverage ?? false,
63
+ coverageConfig: config.coverageConfig,
64
+ debug: config.debug ?? false,
65
+ files: config.files,
66
+ hostname: config.hostname,
67
+ logger: config.logger.constructor.name,
68
+ middleware: [],
69
+ nodeResolve: config.nodeResolve,
70
+ plugins: config.plugins.map( plugin => ( {
71
+ name: plugin.name,
72
+ injectWebSocket: plugin.injectWebSocket ?? false
73
+ } ) ),
74
+ port: config.port,
75
+ protocol: config.protocol,
76
+ reporters: config.reporters.length,
77
+ rootDir: config.rootDir,
78
+ testFramework: ( config.testFramework ) ? relative( config.rootDir, config.testFramework.path ) : null,
79
+ testRunnerHtml: config.testRunnerHtml?.name,
80
+ testsFinishTimeout: config.testsFinishTimeout,
81
+ testsStartTimeout: config.testsStartTimeout,
82
+ watch: config.watch,
83
+ http2: config.http2 ?? null,
84
+ sslKey: config.sslKey ?? null,
85
+ sslCert: config.sslCert ?? null,
86
+ manual: config.manual ?? false,
87
+ open: config.open ?? false,
88
+ mimeTypes: config.mimeTypes ?? null,
89
+ }
90
+ _report.testFiles = testFiles.map( testFile => relative( config.rootDir, testFile ) )
91
+ _report.browserNames = browserNames
92
+ _report.startTime = startTime
93
+ },
94
+
95
+ /**
96
+ * Called once when the test runner stops. This can be used to write a test
97
+ * report to disk for regular test runs.
98
+ */
99
+ stop( {
100
+ sessions,
101
+ testCoverage,
102
+ /*focusedTestFile*/
103
+ } ) {
104
+ if ( !_reportResults && _debug ) {
105
+ _logger.warn( yellow( 'Do not report global results.' ) )
106
+ return
107
+ }
108
+
109
+
110
+ // Update globals
111
+ _report.endTime = ( new Date() ).getTime()
112
+
113
+ // apply session map results
114
+ for ( const session of sessions ) {
115
+ _report.sessions[ session.id ] = {
116
+ id: session.id,
117
+ group: {
118
+ name: session.group.name,
119
+ testFiles: session.group.testFiles,
120
+ browsers: session.group.browsers.map( browser => ( {
121
+ name: browser.name,
122
+ type: browser.type,
123
+ concurrency: browser.concurrency,
124
+ } ) ),
125
+ sessionIds: session.group.sessionIds,
126
+ testRunnerHtml: session.group.testRunnerHtml?.name,
127
+ },
128
+ // debug: false, // Ignore because always false
129
+ browser: {
130
+ name: session.browser.name,
131
+ type: session.browser.type,
132
+ concurrency: session.browser.concurrency,
133
+ },
134
+ testFile: session.testFile,
135
+ testRun: session.testRun,
136
+ status: session.status,
137
+ passed: session.passed,
138
+ errors: session.errors,
139
+ testResults: session.testResults,
140
+ logs: session.logs,
141
+ request404s: session.request404s,
142
+ // testCoverage: session.testCoverage,
143
+ }
144
+ }
145
+
146
+ _report.testCoverage = ( testCoverage ) ? {
147
+ passed: testCoverage.passed,
148
+ coverageMap: testCoverage.coverageMap.toJSON(),
149
+ summary: testCoverage.summary.toJSON(),
150
+ } : null
151
+
152
+ const outputDirectory = dirname( _reportFilePath )
153
+ if ( !existsSync( outputDirectory ) ) {
154
+ if ( _debug ) _logger.log( 'Creating', green( outputDirectory ) )
155
+ mkdirSync( outputDirectory, { recursive: true } )
156
+ }
157
+
158
+ _logger.log( 'Generate', green( _reportFilePath ) )
159
+ writeFileSync( _reportFilePath, JSON.stringify( _report, null, 2 ) )
160
+ },
161
+
162
+ onTestRunStarted( testRun ) {
163
+ if ( _debug ) _logger.log( `onTestRunStarted: ${ testRun }` )
164
+ },
165
+ onTestRunFinished( testRun, sessions, testCoverage, focusedTestFile ) {
166
+ if ( _debug ) _logger.log( `onTestRunFinished: ${ focusedTestFile }` )
167
+ },
168
+ reportTestFileResults( {
169
+ logger,
170
+ sessionsForTestFile,
171
+ testFile,
172
+ testRun
173
+ } ) {
174
+ if ( _debug ) _logger.log( `reportTestFileResults: ${ testFile }` )
175
+ },
176
+
177
+ /**
178
+ * Called when test progress should be rendered to the terminal. This is called
179
+ * any time there is a change in the test runner to display the latest status.
180
+ *
181
+ * This function should return the test report as a string. Previous results from this
182
+ * function are overwritten each time it is called, they are rendered "dynamically"
183
+ * to the terminal so that the progress bar is live updating.
184
+ */
185
+ getTestProgress( {
186
+ config,
187
+ sessions,
188
+ testFiles,
189
+ startTime,
190
+ testRun,
191
+ focusedTestFile,
192
+ testCoverage,
193
+ } ) {
194
+ if ( !_reportProgress ) {
195
+ return
196
+ }
197
+
198
+ const numberOfSessions = sessions.length
199
+ const numberOfFinished = sessions.filter( session => session.status === SESSION_STATUS.FINISHED ).length
200
+
201
+ let progress
202
+ if ( numberOfFinished === numberOfSessions ) {
203
+ progress = null
204
+ } else {
205
+ const advancementPercent = Math.round( ( numberOfFinished / numberOfSessions ) * 100 )
206
+ progress = [
207
+ `Progress: ${ numberOfFinished }/${ numberOfSessions } (${ advancementPercent }%)`
208
+ ]
209
+ }
210
+
211
+ return progress
212
+
213
+ }
214
+
215
+ }
216
+
217
+ }
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # [v6.0.0](https://github.com/Itee/itee-validators/compare/v5.6.0...v6.0.0) (2025-11-05)
2
+
3
+ ## ✨ New Features
4
+ - [`6e706ed`](https://github.com/Itee/itee-validators/commit/6e706ed) (benchmarks) re-introduce benchmarks frontend with web test runner, configs and new code
5
+
6
+ ## 🐛 Bug Fixes
7
+ - [`31c3572`](https://github.com/Itee/itee-validators/commit/31c3572) (gulpfile) fix broken import links
8
+ - [`876ba94`](https://github.com/Itee/itee-validators/commit/876ba94) (run-tests) fix task displayName
9
+
10
+ ## 💥 Breaking Changes
11
+ - [`a6f1255`](https://github.com/Itee/itee-validators/commit/a6f1255) (node) drop nodejs v18 support and add nodejs v24
12
+
1
13
  # [v5.6.0](https://github.com/Itee/itee-validators/compare/v5.5.1...v5.6.0) (2025-10-18)
2
14
 
3
15
  ## ✨ New Features