Skip to content

Commit 42fa7b2

Browse files
committed
test(core): support vitest
1 parent 693d4aa commit 42fa7b2

28 files changed

Lines changed: 8438 additions & 13132 deletions

angular.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
"build": {
1313
"builder": "@angular/build:ng-packagr",
1414
"options": {
15-
"tsConfig": "libs/core/tsconfig.lib.json",
1615
"project": "libs/core/ng-package.json"
1716
},
1817
"configurations": {
1918
"production": {
2019
"tsConfig": "libs/core/tsconfig.lib.prod.json"
20+
},
21+
"development": {
22+
"tsConfig": "libs/core/tsconfig.lib.json"
2123
}
2224
},
2325
"defaultConfiguration": "production"
@@ -26,7 +28,7 @@
2628
"builder": "@angular/build:unit-test",
2729
"options": {
2830
"tsConfig": "tsconfig.spec.json",
29-
"polyfills": ["zone.js", "zone.js/testing"]
31+
"runner": "vitest"
3032
}
3133
}
3234
}
@@ -40,12 +42,14 @@
4042
"build": {
4143
"builder": "@angular/build:ng-packagr",
4244
"options": {
43-
"project": "libs/components/ng-package.json",
44-
"tsConfig": "libs/components/tsconfig.lib.json"
45+
"project": "libs/components/ng-package.json"
4546
},
4647
"configurations": {
4748
"production": {
4849
"tsConfig": "libs/components/tsconfig.lib.prod.json"
50+
},
51+
"development": {
52+
"tsConfig": "libs/components/tsconfig.lib.json"
4953
}
5054
},
5155
"defaultConfiguration": "production"
@@ -54,7 +58,7 @@
5458
"builder": "@angular/build:unit-test",
5559
"options": {
5660
"tsConfig": "tsconfig.spec.json",
57-
"polyfills": ["zone.js", "zone.js/testing"]
61+
"runner": "vitest"
5862
}
5963
}
6064
}

libs/components/eslint.config.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,12 @@ export default defineScAngularConfig(
2828
'no-undef': 'off',
2929
},
3030
},
31+
{
32+
files: ['**/*.spec.ts', '**/*.test.ts'],
33+
rules: {
34+
'@typescript-eslint/no-unsafe-member-access': 'off',
35+
'@typescript-eslint/no-unsafe-call': 'off',
36+
'@typescript-eslint/no-unsafe-return': 'off',
37+
}
38+
}
3139
)

libs/core/eslint.config.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,12 @@ export default defineScAngularConfig(
3636
'no-undef': 'off',
3737
},
3838
},
39+
{
40+
files: ['**/*.spec.ts', '**/*.test.ts'],
41+
rules: {
42+
'@typescript-eslint/no-unsafe-member-access': 'off',
43+
'@typescript-eslint/no-unsafe-call': 'off',
44+
'@typescript-eslint/no-unsafe-return': 'off',
45+
}
46+
}
3947
)

libs/core/src/lib/http/http-date.interceptor.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { HttpTestingController, provideHttpClientTesting } from '@angular/common
99
import { ClassProvider } from '@angular/core'
1010
import { TestBed } from '@angular/core/testing'
1111
import { firstValueFrom } from 'rxjs'
12-
import { describe, it, expect, beforeEach, vi } from 'vitest'
12+
import { beforeEach, describe, expect, it, vi } from 'vitest'
1313

1414
import { HttpDateInterceptor } from './http-date.interceptor'
1515

libs/core/src/lib/local-storage/local-storage.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ClassProvider, ValueProvider } from '@angular/core'
22
import { TestBed } from '@angular/core/testing'
33
import { firstValueFrom, scan, shareReplay } from 'rxjs'
4-
import { describe, it, expect, beforeEach, vi } from 'vitest'
4+
import { beforeEach, describe, expect, it, vi } from 'vitest'
55

66
import { MockStorage } from '../../../test'
77
import { WindowRef } from '../window/window-ref.service'

libs/core/src/lib/logger/helper/leading-zero.function.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { describe, it, expect } from 'vitest'
1+
import { describe, expect,it } from 'vitest'
2+
23
import { leadingZero } from './leading-zero.function'
34

45
describe('leadingZero', () => {

libs/core/src/lib/logger/logger.service.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { Component, Directive, inject, Injectable, InjectionToken, PLATFORM_ID }
22
import { TestBed } from '@angular/core/testing'
33
import { By } from '@angular/platform-browser'
44
import { Logger, LogLevel, LogTransport } from '@shiftcode/logger'
5-
import { LoggerService } from '@shiftcode/ngx-core'
6-
import { describe, it, expect, beforeEach, vi } from 'vitest'
5+
import { beforeEach, describe, expect, it, vi } from 'vitest'
6+
7+
import { LoggerService } from './logger.service'
78

89
interface MockLogTransportConfig {
910
logLevel: LogLevel
@@ -115,3 +116,4 @@ describe('MyDirective', () => {
115116
expect(loggerSpy).toHaveBeenCalledWith('doing something')
116117
})
117118
})
119+

libs/core/src/lib/logger/remote/remote-log.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { HttpTestingController, provideHttpClientTesting } from '@angular/common
33
import { FactoryProvider, ValueProvider } from '@angular/core'
44
import { TestBed } from '@angular/core/testing'
55
import { createJsonLogObjectData, LogLevel } from '@shiftcode/logger'
6-
import { describe, it, expect, vi } from 'vitest'
6+
import { describe, expect, it, vi } from 'vitest'
77

88
import { LOG_REQUEST_INFO_FN } from '../log-request-info-fn.token'
99
import { LogRequestInfoFn } from '../log-request-info-fn.type'

libs/core/src/lib/origin/ensure-origin.interceptor.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { HttpClient, HttpRequest, provideHttpClient, withInterceptors } from '@angular/common/http'
22
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing'
33
import { TestBed } from '@angular/core/testing'
4-
import { describe, it, expect, beforeEach, vi } from 'vitest'
4+
import { beforeEach, describe, expect, it, vi } from 'vitest'
55

66
import { ensureOriginInterceptor } from './ensure-origin.interceptor'
77
import { ORIGIN } from './origin.token'

libs/core/src/lib/origin/provide-origin-from-env.function.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { PLATFORM_ID } from '@angular/core'
22
import { TestBed } from '@angular/core/testing'
3-
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
3+
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
44

55
import { ORIGIN } from './origin.token'
66
import { provideOriginFromEnv } from './provide-origin-from-env.function'

0 commit comments

Comments
 (0)