Skip to content

Commit 9041175

Browse files
CLOUDP-295956: Refactor + add testing for IPA metrics collection
1 parent 938f9a6 commit 9041175

File tree

13 files changed

+73004
-73
lines changed

13 files changed

+73004
-73
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
# Tool generated files
1919
*.idea
2020
*.vscode
21+
*.DS_Store
2122

2223
*.out
2324
**/*ipa-collector-results-combined.log

babel.config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
{
2-
"presets": ["@babel/preset-env"]
2+
"presets": ["@babel/preset-env"],
3+
"plugins": [
4+
"babel-plugin-transform-import-meta"]
35
}

package-lock.json

Lines changed: 52 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"^.+\\.[t|j]sx?$": "babel-jest"
1515
},
1616
"testPathIgnorePatterns": [
17-
"__helpers__"
17+
"__helpers__",
18+
"metrics/data"
1819
]
1920
},
2021
"dependencies": {
@@ -34,6 +35,7 @@
3435
"@eslint/js": "^9.18.0",
3536
"@jest/globals": "^29.7.0",
3637
"@stoplight/types": "^14.1.1",
38+
"babel-plugin-transform-import-meta": "^2.3.2",
3739
"eslint": "^9.18.0",
3840
"eslint-plugin-require-extensions": "^0.1.3",
3941
"globals": "^15.14.0",

tools/spectral/ipa/__tests__/metrics/collector.test.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
import { beforeEach, describe, expect, it } from '@jest/globals';
1+
import { beforeEach, describe, expect, it, jest } from '@jest/globals';
22
import collector, { EntryType } from '../../metrics/collector';
33
import * as fs from 'node:fs';
44

55
jest.mock('node:fs');
66

7-
describe('Collector Class', () => {
7+
describe('tools/spectral/ipa/metrics/collector.js', () => {
88
const expectedOutput = {
99
violations: [
1010
{ componentId: 'example.component', ruleName: 'rule-1' },
1111
{ componentId: 'example.component', ruleName: 'rule-2' },
1212
],
1313
adoptions: [{ componentId: 'example.component', ruleName: 'rule-3' }],
14-
exceptions: [{ componentId: 'example.component', ruleName: 'rule-4', exceptionReason: 'exception-reason' }],
14+
exceptions: [
15+
{
16+
componentId: 'example.component',
17+
ruleName: 'rule-4',
18+
exceptionReason: 'exception-reason',
19+
},
20+
],
1521
};
1622

1723
beforeEach(() => {

0 commit comments

Comments
 (0)