@itee/benchmarks-framework 1.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.
package/.czrc ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "path": "./node_modules/cz-emoji",
3
+ "config": {
4
+ "cz-emoji": {}
5
+ }
6
+ }
@@ -0,0 +1,28 @@
1
+ # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
+ # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3
+
4
+ name: json-reporter CI
5
+
6
+ on:
7
+ push:
8
+ branches: [ master ]
9
+ pull_request:
10
+ branches: [ master ]
11
+
12
+ jobs:
13
+ publish:
14
+ runs-on: ubuntu-latest
15
+ env:
16
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
18
+ steps:
19
+ - name: Use Node.js ${{ matrix.node-version }}
20
+ uses: actions/setup-node@v2
21
+ with:
22
+ node-version: "lts/*"
23
+ - name: Checkout ${{ env.GITHUB_REPOSITORY }}
24
+ uses: actions/checkout@v2
25
+ - name: Install dependencies
26
+ run: npm ci
27
+ - name: Semantic Release
28
+ run: npx semantic-release
package/.releaserc.mjs ADDED
@@ -0,0 +1,94 @@
1
+ import { execSync } from 'node:child_process'
2
+
3
+ // Git utils
4
+
5
+ function getLocalRepoUrl() {
6
+ const topLevelDir = execSync( 'git rev-parse --show-toplevel' )
7
+ .toString()
8
+ .trim()
9
+
10
+ return `file://${ topLevelDir }/.git`
11
+ }
12
+
13
+ function getCurrentBranch() {
14
+ return execSync( 'git rev-parse --abbrev-ref HEAD' )
15
+ .toString()
16
+ .trim()
17
+ }
18
+
19
+ // Plugins sub-configs
20
+
21
+ function getGitmojiPlugin() {
22
+ return [
23
+ 'semantic-release-gitmoji', {
24
+ 'releaseRules': {
25
+ 'major': [
26
+ ':boom:'
27
+ ],
28
+ 'minor': [
29
+ ':sparkles:'
30
+ ],
31
+ 'patch': [
32
+ ':art:', ':zap:', ':fire:', ':bug:', ':ambulance:', ':pencil:', ':rocket:', ':lipstick:', ':white_check_mark:', ':lock:', ':apple:', ':penguin:', ':checkered_flag:', ':robot:',
33
+ ':green_apple:', ':rotating_light:', ':green_heart:', ':arrow_down:', ':pushpin:', ':construction_worker:', ':chart_with_upwards_trend:', ':recycle:', ':whale:',
34
+ ':heavy_plus_sign:', ':heavy_minus_sign:', ':wrench:', ':globe_with_meridians:', ':pencil2:', ':poop:', ':rewind:', ':package:', ':alien:', ':truck:', ':page_facing_up:',
35
+ ':bento:', ':ok_hand:', ':wheelchair:', ':bulb:', ':beers:', ':speech_balloon:', ':card_file_box:', ':loud_sound:', ':mute:', ':busts_in_silhouette:', ':children_crossing:',
36
+ ':building_construction:', ':iphone:', ':clown_face:', ':see_no_evil:', ':camera_flash:', ':alembic:', ':mag:', ':wheel_of_dharma:', ':label:', ':seedling:', ':dizzy:',
37
+ ':wastebasket:', ':passport_control:', ':adhesive_bandage:', ':monocle_face:', ':coffin:', ':test_tube:', ':necktie:', ':stethoscope:', ':bricks:', ':technologist:'
38
+ ]
39
+ }
40
+ }
41
+ ]
42
+ }
43
+
44
+ function getChangelogPlugin() {
45
+ return '@semantic-release/changelog'
46
+ }
47
+
48
+ function getNpmPlugin() {
49
+ return '@semantic-release/npm'
50
+ }
51
+
52
+ function getGithubPlugin() {
53
+ return '@semantic-release/github'
54
+ }
55
+
56
+ function getGitPlugin() {
57
+ return [
58
+ '@semantic-release/git', {
59
+ 'assets': [
60
+ 'builds/**', 'docs/**', 'package.json', 'CHANGELOG.md'
61
+ ],
62
+ 'message': 'chore(release): v${nextRelease.version}'
63
+ }
64
+ ]
65
+ }
66
+
67
+ // Configuration selection
68
+
69
+ function isDryRun() {
70
+ return process.argv.includes( '--dry-run' )
71
+ }
72
+
73
+ function getDryRunConfig() {
74
+ return {
75
+ repositoryUrl: getLocalRepoUrl(),
76
+ branches: getCurrentBranch(),
77
+ plugins: [
78
+ getGitmojiPlugin()
79
+ ],
80
+ }
81
+ }
82
+
83
+ function getCIConfig() {
84
+ return {
85
+ branch: 'master',
86
+ plugins: [
87
+ getGitmojiPlugin(), getChangelogPlugin(), getNpmPlugin(), getGithubPlugin(), getGitPlugin()
88
+ ]
89
+ }
90
+ }
91
+
92
+ // Module
93
+
94
+ export default isDryRun() ? getDryRunConfig() : getCIConfig()
package/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ # v1.0.0 (2025-12-09)
2
+
3
+ ## ✨ New Features
4
+ - [`5d46e77`](https://github.com/Itee/benchmarks-framework/commit/5d46e77) (global) add basic dev template and sources
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Tristan VALCKE
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -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
+ } )()
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@itee/benchmarks-framework",
3
+ "version": "1.0.0",
4
+ "description": "A dedicated web test runner framework for the Benchmarks.js library to allow to run benchmarks in front side",
5
+ "keywords": [
6
+ "itee",
7
+ "test-runner",
8
+ "framework"
9
+ ],
10
+ "author": {
11
+ "name": "Itee (Tristan Valcke)",
12
+ "url": "https://github.com/Itee"
13
+ },
14
+ "contributors": [],
15
+ "license": "MIT",
16
+ "private": false,
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/Itee/benchmarks-framework.git"
20
+ },
21
+ "type": "module",
22
+ "main": "benchmarks-framework.js",
23
+ "homepage": "",
24
+ "man": "",
25
+ "bugs": {
26
+ "url": "https://github.com/Itee/benchmarks-framework/issues"
27
+ },
28
+ "engines": {
29
+ "node": ">=20"
30
+ },
31
+ "os": [
32
+ "win32",
33
+ "linux"
34
+ ],
35
+ "cpu": [
36
+ "x64",
37
+ "ia32"
38
+ ],
39
+ "scripts": {
40
+ "semantic-release": "semantic-release --dry-run --no-ci",
41
+ "semantic-release-force": "semantic-release --no-ci"
42
+ },
43
+ "dependencies": {
44
+ "@web/test-runner-core": "^0.13.4"
45
+ },
46
+ "devDependencies": {
47
+ "@semantic-release/changelog": "^6.0.3",
48
+ "@semantic-release/git": "^10.0.1",
49
+ "@semantic-release/github": "^11.0.6",
50
+ "@semantic-release/npm": "^12.0.2",
51
+ "cz-emoji": "^1.3.2-canary.2",
52
+ "semantic-release": "^24.2.9",
53
+ "semantic-release-gitmoji": "^1.6.8"
54
+ }
55
+ }