@regressionproof/jest-reporter 0.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/.nvmrc +1 -0
- package/.vscode/launch.json +58 -0
- package/.vscode/settings.json +67 -0
- package/.vscode/tasks.json +112 -0
- package/eslint.config.mjs +3 -0
- package/package.json +91 -0
- package/src/.spruce/settings.json +16 -0
- package/src/config/loadConfig.ts +76 -0
- package/src/index.ts +75 -0
- package/src/transformers/transformResults.ts +44 -0
- package/tsconfig.dist.json +26 -0
- package/tsconfig.json +27 -0
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
lts/*
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2.0",
|
|
3
|
+
"configurations": [
|
|
4
|
+
{
|
|
5
|
+
"type": "node",
|
|
6
|
+
"request": "attach",
|
|
7
|
+
"name": "attach.tests",
|
|
8
|
+
"port": 5200,
|
|
9
|
+
"restart": true,
|
|
10
|
+
"timeout": 10000
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"type": "node",
|
|
14
|
+
"request": "launch",
|
|
15
|
+
"name": "test.file",
|
|
16
|
+
"runtimeExecutable": "node",
|
|
17
|
+
"runtimeArgs": [
|
|
18
|
+
"--inspect-brk",
|
|
19
|
+
"--trace-warnings",
|
|
20
|
+
"${workspaceFolder}/node_modules/.bin/jest",
|
|
21
|
+
"${fileBasenameNoExtension}",
|
|
22
|
+
"--detectOpenHandles"
|
|
23
|
+
],
|
|
24
|
+
"cwd": "${workspaceFolder}",
|
|
25
|
+
"console": "integratedTerminal",
|
|
26
|
+
"internalConsoleOptions": "neverOpen"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"type": "node",
|
|
30
|
+
"request": "launch",
|
|
31
|
+
"name": "test.all",
|
|
32
|
+
"runtimeExecutable": "node",
|
|
33
|
+
"runtimeArgs": [
|
|
34
|
+
"--inspect-brk",
|
|
35
|
+
"--trace-warnings",
|
|
36
|
+
"${workspaceFolder}/node_modules/.bin/jest"
|
|
37
|
+
],
|
|
38
|
+
"cwd": "${workspaceFolder}",
|
|
39
|
+
"console": "integratedTerminal",
|
|
40
|
+
"internalConsoleOptions": "neverOpen"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"type": "node",
|
|
44
|
+
"request": "launch",
|
|
45
|
+
"name": "boot",
|
|
46
|
+
"runtimeExecutable": "yarn",
|
|
47
|
+
"runtimeArgs": [
|
|
48
|
+
"run",
|
|
49
|
+
"--inspect-brk",
|
|
50
|
+
"--trace-warnings",
|
|
51
|
+
"boot"
|
|
52
|
+
],
|
|
53
|
+
"cwd": "${workspaceFolder}",
|
|
54
|
+
"console": "integratedTerminal",
|
|
55
|
+
"internalConsoleOptions": "neverOpen"
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"debug.node.autoAttach": "on",
|
|
3
|
+
"git.ignoreLimitWarning": true,
|
|
4
|
+
"javascript.validate.enable": false,
|
|
5
|
+
"files.watcherExclude": {
|
|
6
|
+
"**/.git/objects/**": true,
|
|
7
|
+
"**/.git/subtree-cache/**": true,
|
|
8
|
+
"**/build/**": true,
|
|
9
|
+
"**/node_modules/**": true,
|
|
10
|
+
},
|
|
11
|
+
"search.exclude": {
|
|
12
|
+
"**/build/**": true,
|
|
13
|
+
"**/node_modules/**": true,
|
|
14
|
+
"**/.next/**": true
|
|
15
|
+
},
|
|
16
|
+
"editor.maxTokenizationLineLength": 20000000,
|
|
17
|
+
"[javascript]": {
|
|
18
|
+
"editor.formatOnSave": false
|
|
19
|
+
},
|
|
20
|
+
"[javascriptreact]": {
|
|
21
|
+
"editor.formatOnSave": false
|
|
22
|
+
},
|
|
23
|
+
"[typescript]": {
|
|
24
|
+
"editor.formatOnSave": false
|
|
25
|
+
},
|
|
26
|
+
"[typescriptreact]": {
|
|
27
|
+
"editor.formatOnSave": false
|
|
28
|
+
},
|
|
29
|
+
"[handlebars]": {
|
|
30
|
+
"editor.formatOnSave": false
|
|
31
|
+
},
|
|
32
|
+
"typescript.tsdk": "node_modules/typescript/lib",
|
|
33
|
+
"cSpell.ignorePaths": [
|
|
34
|
+
"**/package-lock.json",
|
|
35
|
+
"**/node_modules/**",
|
|
36
|
+
"**/build/**",
|
|
37
|
+
"**/vscode-extension/**",
|
|
38
|
+
"**/.git/objects/**",
|
|
39
|
+
".vscode",
|
|
40
|
+
".spruce"
|
|
41
|
+
],
|
|
42
|
+
"cSpell.words": [
|
|
43
|
+
"arkit",
|
|
44
|
+
"autogenerated",
|
|
45
|
+
"scrollable",
|
|
46
|
+
"serializable"
|
|
47
|
+
],
|
|
48
|
+
"debug.javascript.unmapMissingSources": true,
|
|
49
|
+
"javascript.preferences.importModuleSpecifier": "relative",
|
|
50
|
+
"typescript.preferences.importModuleSpecifier": "relative",
|
|
51
|
+
"eslint.useFlatConfig": true,
|
|
52
|
+
"eslint.enable": true,
|
|
53
|
+
"eslint.validate": [
|
|
54
|
+
"javascript",
|
|
55
|
+
"javascriptreact",
|
|
56
|
+
"typescript",
|
|
57
|
+
"typescriptreact"
|
|
58
|
+
],
|
|
59
|
+
"eslint.workingDirectories": [
|
|
60
|
+
"./"
|
|
61
|
+
],
|
|
62
|
+
"typescript.validate.enable": true,
|
|
63
|
+
"editor.formatOnSave": false,
|
|
64
|
+
"editor.codeActionsOnSave": {
|
|
65
|
+
"source.fixAll.eslint": "always"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "2.0.0",
|
|
3
|
+
"tasks": [
|
|
4
|
+
{
|
|
5
|
+
"type": "npm",
|
|
6
|
+
"script": "watch.build.dev",
|
|
7
|
+
"group": "build",
|
|
8
|
+
"label": "watch.build.dev & problem.watcher",
|
|
9
|
+
"isBackground": true,
|
|
10
|
+
"runOptions": {
|
|
11
|
+
"runOn": "folderOpen"
|
|
12
|
+
},
|
|
13
|
+
"promptOnClose": false,
|
|
14
|
+
"presentation": {
|
|
15
|
+
"focus": false,
|
|
16
|
+
"reveal": "never"
|
|
17
|
+
},
|
|
18
|
+
"problemMatcher": {
|
|
19
|
+
"base": "$tsc-watch",
|
|
20
|
+
"applyTo": "allDocuments"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"label": "test.file",
|
|
25
|
+
"command": "spruce",
|
|
26
|
+
"args": [
|
|
27
|
+
"test",
|
|
28
|
+
"--inspect",
|
|
29
|
+
"5200",
|
|
30
|
+
"--pattern",
|
|
31
|
+
"${fileBasenameNoExtension}",
|
|
32
|
+
"--watchMode",
|
|
33
|
+
"standard"
|
|
34
|
+
],
|
|
35
|
+
"promptOnClose": false,
|
|
36
|
+
"group": {
|
|
37
|
+
"kind": "test",
|
|
38
|
+
"isDefault": true
|
|
39
|
+
},
|
|
40
|
+
"presentation": {
|
|
41
|
+
"reveal": "always",
|
|
42
|
+
"panel": "dedicated",
|
|
43
|
+
},
|
|
44
|
+
"problemMatcher": []
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"label": "test.reporter",
|
|
48
|
+
"command": "spruce",
|
|
49
|
+
"args": [
|
|
50
|
+
"test",
|
|
51
|
+
"--shouldHoldAtStart",
|
|
52
|
+
"true",
|
|
53
|
+
"--watchMode",
|
|
54
|
+
"smart"
|
|
55
|
+
],
|
|
56
|
+
"promptOnClose": false,
|
|
57
|
+
"group": "test",
|
|
58
|
+
"runOptions": {
|
|
59
|
+
"runOn": "folderOpen"
|
|
60
|
+
},
|
|
61
|
+
"presentation": {
|
|
62
|
+
"panel": "shared",
|
|
63
|
+
"focus": true,
|
|
64
|
+
"reveal": "always"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"label": "spruce",
|
|
69
|
+
"type": "shell",
|
|
70
|
+
"command": "spruce ${input:spruceCommand}",
|
|
71
|
+
"problemMatcher": [],
|
|
72
|
+
"presentation": {
|
|
73
|
+
"reveal": "always",
|
|
74
|
+
"focus": true,
|
|
75
|
+
"panel": "new",
|
|
76
|
+
"clear": false
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"label": "shell",
|
|
81
|
+
"type": "shell",
|
|
82
|
+
"command": "${input:command} ${input:optionsCommand}",
|
|
83
|
+
"problemMatcher": [],
|
|
84
|
+
"presentation": {
|
|
85
|
+
"reveal": "always",
|
|
86
|
+
"focus": true,
|
|
87
|
+
"panel": "new",
|
|
88
|
+
"clear": false
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"inputs": [
|
|
93
|
+
{
|
|
94
|
+
"id": "spruceCommand",
|
|
95
|
+
"description": "spruce command",
|
|
96
|
+
"default": "create.test",
|
|
97
|
+
"type": "promptString"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"id": "command",
|
|
101
|
+
"description": "command",
|
|
102
|
+
"default": "yarn",
|
|
103
|
+
"type": "promptString"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"id": "optionsCommand",
|
|
107
|
+
"description": "optionsCommand",
|
|
108
|
+
"default": "add",
|
|
109
|
+
"type": "promptString"
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@regressionproof/jest-reporter",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"main": "./build/index.js",
|
|
8
|
+
"types": "./build/index.d.ts",
|
|
9
|
+
"module": "./build/esm/index.js",
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": {
|
|
14
|
+
"types": "./build/esm/index.d.ts",
|
|
15
|
+
"default": "./build/esm/index.js"
|
|
16
|
+
},
|
|
17
|
+
"require": {
|
|
18
|
+
"types": "./build/index.d.ts",
|
|
19
|
+
"default": "./build/index.js"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build.ci": "yarn run build.tsc && yarn run build.resolve-paths && yarn run lint",
|
|
25
|
+
"build.dev": "yarn run build.tsc --sourceMap ; yarn run resolve-paths.lint",
|
|
26
|
+
"build.copy-files": "mkdir -p build && rsync -avzq --exclude='*.ts' ./src/ ./build/",
|
|
27
|
+
"build.resolve-paths": "resolve-path-aliases --target build --patterns '**/*.js,**/*.d.ts'",
|
|
28
|
+
"build.tsc": "yarn run build.copy-files && tsc",
|
|
29
|
+
"build.dist": "tsc --project tsconfig.dist.json && yarn build.resolve-paths && mv build esm && yarn build.esm-postbuild && yarn build.tsc && yarn build.resolve-paths && mv esm build/",
|
|
30
|
+
"build.esm-postbuild": "esm-postbuild --target esm --patterns '**/*.js'",
|
|
31
|
+
"clean": "yarn run clean.build",
|
|
32
|
+
"clean.all": "yarn run clean.dependencies && yarn run clean.build",
|
|
33
|
+
"clean.build": "rm -rf build/",
|
|
34
|
+
"clean.dependencies": "rm -rf node_modules/ package-lock.json yarn.lock",
|
|
35
|
+
"fix.lint": "eslint --fix --cache '**/*.ts'",
|
|
36
|
+
"lint": "eslint --cache '**/*.ts'",
|
|
37
|
+
"lint.tsc": "tsc -p . --noEmit",
|
|
38
|
+
"post.watch.build": "yarn run build.copy-files && yarn run build.resolve-paths",
|
|
39
|
+
"rebuild": "yarn run clean.all && yarn install && yarn run build.dev",
|
|
40
|
+
"update.dependencies": "yarn run clean.dependencies && yarn",
|
|
41
|
+
"resolve-paths.lint": "yarn run build.resolve-paths ; yarn run lint",
|
|
42
|
+
"test": "jest --passWithNoTests",
|
|
43
|
+
"watch.build.dev": "tsc-watch --sourceMap --onCompilationComplete 'yarn run post.watch.build'",
|
|
44
|
+
"watch.rebuild": "yarn run clean.all && yarn install && yarn run watch.build.dev",
|
|
45
|
+
"watch.tsc": "tsc -w"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@regressionproof/snapshotter": "^0.0.1"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@jest/reporters": "^30.2.0",
|
|
52
|
+
"@sprucelabs/esm-postbuild": "^9.0.13",
|
|
53
|
+
"@sprucelabs/jest-json-reporter": "^10.0.19",
|
|
54
|
+
"@sprucelabs/resolve-path-aliases": "^4.0.13",
|
|
55
|
+
"@sprucelabs/test": "^11.1.0",
|
|
56
|
+
"@sprucelabs/test-utils": "^7.2.3",
|
|
57
|
+
"@types/jest": "^29.5.14",
|
|
58
|
+
"@types/node": "^25.0.5",
|
|
59
|
+
"chokidar-cli": "^3.0.0",
|
|
60
|
+
"eslint": "^9.39.2",
|
|
61
|
+
"eslint-config-spruce": "^11.2.26",
|
|
62
|
+
"jest": "^30.2.0",
|
|
63
|
+
"jest-circus": "^30.2.0",
|
|
64
|
+
"prettier": "^3.7.4",
|
|
65
|
+
"ts-node": "^10.9.2",
|
|
66
|
+
"tsc-watch": "^7.2.0",
|
|
67
|
+
"typescript": "^5.9.3"
|
|
68
|
+
},
|
|
69
|
+
"description": "Train LLM's on TDD using jest!",
|
|
70
|
+
"skill": {
|
|
71
|
+
"namespace": "regressionproof-jest-reporter"
|
|
72
|
+
},
|
|
73
|
+
"jest": {
|
|
74
|
+
"testRunner": "jest-circus/runner",
|
|
75
|
+
"maxWorkers": 4,
|
|
76
|
+
"testTimeout": 120000,
|
|
77
|
+
"testEnvironment": "node",
|
|
78
|
+
"testPathIgnorePatterns": [
|
|
79
|
+
"<rootDir>/tmp/",
|
|
80
|
+
"<rootDir>/src/",
|
|
81
|
+
"<rootDir>/node_modules/",
|
|
82
|
+
"<rootDir>/build/__tests__/testDirsAndFiles/"
|
|
83
|
+
],
|
|
84
|
+
"testMatch": [
|
|
85
|
+
"**/__tests__/**/*.test.js?(x)"
|
|
86
|
+
],
|
|
87
|
+
"moduleNameMapper": {
|
|
88
|
+
"^#spruce/(.*)$": "<rootDir>/build/.spruce/$1"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { execSync } from 'child_process'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import os from 'os'
|
|
4
|
+
import path from 'path'
|
|
5
|
+
|
|
6
|
+
export function loadConfig(cwd: string): ReporterConfig | null {
|
|
7
|
+
const projectName = detectProjectName(cwd)
|
|
8
|
+
if (!projectName) {
|
|
9
|
+
return null
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const baseDir = path.join(os.homedir(), '.regressionproof')
|
|
13
|
+
const configPath = path.join(baseDir, projectName, 'config.json')
|
|
14
|
+
|
|
15
|
+
if (!fs.existsSync(configPath)) {
|
|
16
|
+
return null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'))
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
projectName,
|
|
23
|
+
mirrorPath: path.join(baseDir, projectName, 'mirror'),
|
|
24
|
+
remote: {
|
|
25
|
+
url: config.remote.url,
|
|
26
|
+
token: config.remote.token,
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function detectProjectName(cwd: string): string | null {
|
|
32
|
+
const localConfigPath = path.join(cwd, '.regressionproof.json')
|
|
33
|
+
if (fs.existsSync(localConfigPath)) {
|
|
34
|
+
const localConfig = JSON.parse(
|
|
35
|
+
fs.readFileSync(localConfigPath, 'utf-8')
|
|
36
|
+
)
|
|
37
|
+
if (localConfig.projectName) {
|
|
38
|
+
return localConfig.projectName
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return getProjectNameFromGit(cwd)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function getProjectNameFromGit(cwd: string): string | null {
|
|
46
|
+
try {
|
|
47
|
+
const remoteUrl = execSync('git remote get-url origin', {
|
|
48
|
+
cwd,
|
|
49
|
+
encoding: 'utf-8',
|
|
50
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
51
|
+
}).trim()
|
|
52
|
+
|
|
53
|
+
const match = remoteUrl.match(/[/:]([^/:]+?)(\.git)?$/)
|
|
54
|
+
return toSlug(match?.[1] ?? '') || null
|
|
55
|
+
} catch {
|
|
56
|
+
return null
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function toSlug(input: string): string {
|
|
61
|
+
return input
|
|
62
|
+
.toLowerCase()
|
|
63
|
+
.replace(/\s+/g, '-')
|
|
64
|
+
.replace(/[^a-z0-9-_]/g, '')
|
|
65
|
+
.replace(/-+/g, '-')
|
|
66
|
+
.replace(/^-|-$/g, '')
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface ReporterConfig {
|
|
70
|
+
projectName: string
|
|
71
|
+
mirrorPath: string
|
|
72
|
+
remote: {
|
|
73
|
+
url: string
|
|
74
|
+
token: string
|
|
75
|
+
}
|
|
76
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AggregatedResult,
|
|
3
|
+
Reporter,
|
|
4
|
+
ReporterOnStartOptions,
|
|
5
|
+
Test,
|
|
6
|
+
TestCaseResult,
|
|
7
|
+
TestContext,
|
|
8
|
+
} from '@jest/reporters'
|
|
9
|
+
import { snapshot } from '@regressionproof/snapshotter'
|
|
10
|
+
import { loadConfig } from './config/loadConfig.js'
|
|
11
|
+
import { transformResults } from './transformers/transformResults.js'
|
|
12
|
+
|
|
13
|
+
export default class RegressionProofReporter implements Reporter {
|
|
14
|
+
private cwd: string
|
|
15
|
+
|
|
16
|
+
public constructor(_globalConfig?: unknown, _reporterConfig?: unknown) {
|
|
17
|
+
this.cwd = process.cwd()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public onRunStart(
|
|
21
|
+
_results: AggregatedResult,
|
|
22
|
+
_options: ReporterOnStartOptions
|
|
23
|
+
): void {}
|
|
24
|
+
|
|
25
|
+
public onTestFileStart(_test: Test): void {}
|
|
26
|
+
|
|
27
|
+
public onTestCaseResult(
|
|
28
|
+
_test: Test,
|
|
29
|
+
_testCaseResult: TestCaseResult
|
|
30
|
+
): void {}
|
|
31
|
+
|
|
32
|
+
public async onRunComplete(
|
|
33
|
+
_testContexts: Set<TestContext>,
|
|
34
|
+
results: AggregatedResult
|
|
35
|
+
): Promise<void> {
|
|
36
|
+
const config = loadConfig(this.cwd)
|
|
37
|
+
|
|
38
|
+
if (!config) {
|
|
39
|
+
console.log(
|
|
40
|
+
'[RegressionProof] No config found. Run `regressionproof init` to set up.'
|
|
41
|
+
)
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const testResults = transformResults(results, this.cwd)
|
|
46
|
+
|
|
47
|
+
console.log(
|
|
48
|
+
`[RegressionProof] ${testResults.summary.passedTests}/${testResults.summary.totalTests} tests passed`
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
const committed = await snapshot({
|
|
53
|
+
sourcePath: this.cwd,
|
|
54
|
+
mirrorPath: config.mirrorPath,
|
|
55
|
+
testResults,
|
|
56
|
+
remote: config.remote,
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
if (committed) {
|
|
60
|
+
console.log('[RegressionProof] Snapshot captured successfully')
|
|
61
|
+
} else {
|
|
62
|
+
console.log('[RegressionProof] No changes to snapshot')
|
|
63
|
+
}
|
|
64
|
+
} catch (err) {
|
|
65
|
+
console.error(
|
|
66
|
+
'[RegressionProof] Failed to capture snapshot:',
|
|
67
|
+
err instanceof Error ? err.message : err
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public getLastError(): Error | void {
|
|
73
|
+
return undefined
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import type { AggregatedResult } from '@jest/reporters'
|
|
3
|
+
import type {
|
|
4
|
+
TestResults,
|
|
5
|
+
SuiteResult,
|
|
6
|
+
TestResult,
|
|
7
|
+
} from '@regressionproof/snapshotter'
|
|
8
|
+
|
|
9
|
+
export function transformResults(
|
|
10
|
+
jestResults: AggregatedResult,
|
|
11
|
+
cwd: string
|
|
12
|
+
): TestResults {
|
|
13
|
+
const suites: SuiteResult[] = jestResults.testResults.map((suiteResult) => {
|
|
14
|
+
const tests: TestResult[] = suiteResult.testResults.map((test) => ({
|
|
15
|
+
name: test.fullName || test.title,
|
|
16
|
+
passed: test.status === 'passed',
|
|
17
|
+
error:
|
|
18
|
+
test.status === 'failed' && test.failureMessages.length > 0
|
|
19
|
+
? test.failureMessages.join('\n\n')
|
|
20
|
+
: undefined,
|
|
21
|
+
}))
|
|
22
|
+
|
|
23
|
+
const suitePassed = tests.every((t) => t.passed)
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
path: path.relative(cwd, suiteResult.testFilePath),
|
|
27
|
+
passed: suitePassed,
|
|
28
|
+
tests,
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
timestamp: new Date().toISOString(),
|
|
34
|
+
summary: {
|
|
35
|
+
totalSuites: jestResults.numTotalTestSuites,
|
|
36
|
+
passedSuites: jestResults.numPassedTestSuites,
|
|
37
|
+
failedSuites: jestResults.numFailedTestSuites,
|
|
38
|
+
totalTests: jestResults.numTotalTests,
|
|
39
|
+
passedTests: jestResults.numPassedTests,
|
|
40
|
+
failedTests: jestResults.numFailedTests,
|
|
41
|
+
},
|
|
42
|
+
suites,
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "ES2020",
|
|
4
|
+
"target": "ES6",
|
|
5
|
+
"lib": ["ES2020", "DOM"],
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"moduleResolution": "node",
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"noImplicitAny": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"noImplicitReturns": true,
|
|
13
|
+
"strict": true,
|
|
14
|
+
"noUnusedLocals": true,
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
"sourceMap": false,
|
|
17
|
+
"outDir": "./build",
|
|
18
|
+
"baseUrl": "src",
|
|
19
|
+
"experimentalDecorators": true,
|
|
20
|
+
"paths": {
|
|
21
|
+
"#spruce/*": [".spruce/*"]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"include": ["./src/*.ts", "./src/**/*.ts"],
|
|
25
|
+
"exclude": ["**/node_modules/*", "build/*", "esm/*"]
|
|
26
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"skipLibCheck": true,
|
|
4
|
+
"module": "CommonJS",
|
|
5
|
+
"esModuleInterop": true,
|
|
6
|
+
"target": "ES2020",
|
|
7
|
+
"lib": ["DOM", "ES2022"],
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"noImplicitAny": true,
|
|
10
|
+
"allowJs": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"noImplicitReturns": true,
|
|
13
|
+
"strict": true,
|
|
14
|
+
"noUnusedLocals": true,
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
"moduleResolution": "node",
|
|
17
|
+
"sourceMap": false,
|
|
18
|
+
"outDir": "build",
|
|
19
|
+
"baseUrl": "src",
|
|
20
|
+
"experimentalDecorators": true,
|
|
21
|
+
"paths": {
|
|
22
|
+
"#spruce/*": [".spruce/*"]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"include": ["./src/*.ts", "./src/**/*.ts", "./src/.spruce/**/*"],
|
|
26
|
+
"exclude": ["build", "esm"]
|
|
27
|
+
}
|