Skip to content

Commit 4e3d29c

Browse files
committed
consolidates test in its own folder and own configs
1 parent da41237 commit 4e3d29c

28 files changed

Lines changed: 80 additions & 22 deletions

eslint.config.mjs

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,31 @@ export default [
88
{
99
ignores: [
1010
'dist/**',
11-
'test/**',
1211
'docs/**',
1312
'node_modules/**',
1413
'dev/**',
14+
'dev-dist/**',
1515
'coverage/**',
1616
],
1717
},
1818
{
19-
files: ['src/**/*.js', 'src/**/*.ts', 'src/**/*.cjs', 'src/**/*.mjs'],
19+
files: ['src/**/*.js', 'src/**/*.cjs', 'src/**/*.mjs'],
20+
languageOptions: {
21+
globals: {
22+
...globals.browser,
23+
...globals.node,
24+
Atomics: 'readonly',
25+
SharedArrayBuffer: 'readonly',
26+
}
27+
},
28+
rules: {
29+
semi: ['error', 'never'],
30+
quotes: ['error', 'single'],
31+
'no-unused-vars': 'off', // handled by TS
32+
}
33+
},
34+
{
35+
files: ['src/**/*.ts'],
2036
plugins: {
2137
'@typescript-eslint': tseslintPlugin,
2238
},
@@ -29,15 +45,47 @@ export default [
2945
SharedArrayBuffer: 'readonly',
3046
},
3147
parser: tsParser,
48+
parserOptions: {
49+
project: ['./tsconfig.json']
50+
},
3251
},
3352
rules: {
3453
semi: ['error', 'never'],
3554
quotes: ['error', 'single'],
36-
'no-unused-vars': 'off', // handled by TS
55+
'no-console': 'warn',
56+
'no-unused-vars': 'off',
3757
'@typescript-eslint/no-unused-vars': ['warn', {
3858
argsIgnorePattern: '^_',
3959
varsIgnorePattern: '^_',
40-
}]
60+
}],
61+
// '@typescript-eslint/no-explicit-any': 'warn', - codebase not ready for this
62+
},
63+
},
64+
{
65+
files: ['test/**/*.ts'],
66+
plugins: {
67+
'@typescript-eslint': tseslintPlugin,
68+
},
69+
languageOptions: {
70+
parser: tsParser,
71+
parserOptions: {
72+
project: ['./tsconfig.test.json'],
73+
},
74+
},
75+
rules: {
76+
semi: ['error', 'never'],
77+
quotes: ['error', 'single'],
78+
'no-console': 'off', // Allow console in tests
79+
'no-undef': 'off', // Tests may define globals
80+
}
81+
},
82+
{
83+
files: ['test/**/**/*.js', 'test/**/*.js'],
84+
rules: {
85+
semi: ['error', 'never'],
86+
quotes: ['error', 'single'],
87+
'no-console': 'off', // Allow console in tests
88+
'no-undef': 'off', // Tests may define globals
4189
}
4290
}
4391
]

jest.config.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
1-
module.exports = {
1+
export default {
2+
collectCoverage: true,
3+
coverageDirectory: 'coverage',
24
preset: 'ts-jest/presets/js-with-babel',
35
testEnvironment: 'jsdom',
46
testEnvironmentOptions: {
57
customExportConditions: ['node']
68
},
7-
moduleNameMapper: {
8-
'^[./a-zA-Z0-9$_-]+\\.ttl$': '<rootDir>/__mocks__/fileMock.js', // '\\.ttl$'
9+
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
10+
transform: {
11+
'^.+\\.[tj]sx?$': ['babel-jest', { configFile: './babel.config.js' }],
912
},
10-
collectCoverage: true,
13+
transformIgnorePatterns: ['/node_modules/(?!lit-html).+\\.js'],
14+
setupFilesAfterEnv: ['./test/helpers/setup.ts'],
15+
testMatch: ['**/?(*.)+(spec|test).[tj]s?(x)'],
16+
roots: ['<rootDir>/src', '<rootDir>/test', '<rootDir>/__mocks__'],
1117
// For some reason Jest is not measuring coverage without the below option.
1218
// Unfortunately, despite `!(.test)`, it still measures coverage of test files as well:
13-
forceCoverageMatch: ['./src/**/*!(.test).ts'],
19+
// forceCoverageMatch: ['./src/**/*!(.test).ts'],
1420
// Since we're only measuring coverage for TypeScript (i.e. added with test infrastructure in place),
1521
// we can be fairly strict. However, if you feel that something is not fit for coverage,
1622
// mention why in a comment and mark it as ignored:
1723
// https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md
18-
coverageThreshold: {
24+
/* coverageThreshold: {
1925
global: {
2026
branches: 10,
2127
functions: 25,
2228
lines: 20,
2329
statements: 20
2430
}
25-
},
26-
setupFilesAfterEnv: ['./jest.setup.ts']
31+
} */
2732
}

src/trustedApplications/trustedApplications.dom.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ function createApplicationEntry (
193193
if (success) {
194194
return updateTable()
195195
}
196-
console.error(uri, errorBody)
196+
// console.error(uri, errorBody)
197197
}
198198
}
199199

src/trustedApplications/__snapshots__/trustedApplications.test.ts.snap renamed to test/unit/__snapshots__/trustedApplications.test.ts.snap

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)