Angular 测试:错误必须有一个源文件来重构
Angular Test: ERROR in Must have a source file to refactor
我正在尝试 运行 ng test
并收到此错误。我怎样才能解决这个问题?甚至不知道这是什么意思。
ERROR in Must have a source file to refactor.
To disable this warning use "ng config -g cli.warnings.versionMismatch false".
Browserslist: caniuse-lite is outdated. Please run next command `npm update`
10% building 3/3 modules 0 active07 01 2020 21:25:31.477:WARN [karma]: No captured browser, open http://localhost:9877/
07 01 2020 21:25:31.537:INFO [karma-server]: Karma v4.1.0 server started at http://0.0.0.0:9877/
07 01 2020 21:25:31.538:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
07 01 2020 21:25:31.551:INFO [launcher]: Starting browser Chrome
ERROR in Must have a source file to refactor.
07 01 2020 21:25:54.710:INFO [Chrome 79.0.3945 (Windows 10.0.0)]: Connected on socket with id
Chrome 79.0.3945 (Windows 10.0.0): Executed 0 of 0 ERROR (0.008 secs / 0 secs)
Chrome 79.0.3945 (Windows 10.0.0): Executed 0 of 0 ERROR (0.008 secs / 0 secs)
检查您的 angular.json 文件并查看构建和测试对象的路径
喜欢
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": ["src/styles.css"],
"scripts": [],
"assets": ["src/favicon.ico", "src/assets"]
}
},
如果这不起作用,请分享您的代码
当您在 angular.json 中提到的路径中缺少源文件(在本例中为 test.ts 文件)时,会发生此错误。
重新检查 angular.json 文件中提到的 test.ts 的路径。
您可以尝试完全重新安装 node 模块 - 它对我有用。
npm ci
我正在尝试 运行 ng test
并收到此错误。我怎样才能解决这个问题?甚至不知道这是什么意思。
ERROR in Must have a source file to refactor.
To disable this warning use "ng config -g cli.warnings.versionMismatch false".
Browserslist: caniuse-lite is outdated. Please run next command `npm update`
10% building 3/3 modules 0 active07 01 2020 21:25:31.477:WARN [karma]: No captured browser, open http://localhost:9877/
07 01 2020 21:25:31.537:INFO [karma-server]: Karma v4.1.0 server started at http://0.0.0.0:9877/
07 01 2020 21:25:31.538:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
07 01 2020 21:25:31.551:INFO [launcher]: Starting browser Chrome
ERROR in Must have a source file to refactor.
07 01 2020 21:25:54.710:INFO [Chrome 79.0.3945 (Windows 10.0.0)]: Connected on socket with id
Chrome 79.0.3945 (Windows 10.0.0): Executed 0 of 0 ERROR (0.008 secs / 0 secs)
Chrome 79.0.3945 (Windows 10.0.0): Executed 0 of 0 ERROR (0.008 secs / 0 secs)
检查您的 angular.json 文件并查看构建和测试对象的路径 喜欢
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": ["src/styles.css"],
"scripts": [],
"assets": ["src/favicon.ico", "src/assets"]
}
},
如果这不起作用,请分享您的代码
当您在 angular.json 中提到的路径中缺少源文件(在本例中为 test.ts 文件)时,会发生此错误。
重新检查 angular.json 文件中提到的 test.ts 的路径。
您可以尝试完全重新安装 node 模块 - 它对我有用。
npm ci