gpt4 book ai didi

node.js - ionic 2 : Test with jasmine and karma error 'ng test'

转载 作者:行者123 更新时间:2023-11-28 20:20:00 24 4
gpt4 key购买 nike

我尝试按照本教程进行操作:

http://lathonez.com/2017/ionic-2-unit-testing/

当我运行“ng test”时出现这个错误:

C:\xampp\htdocs\AppFineMobile>ng test
27 03 2017 11:55:00.556:ERROR [preprocess]: Can not load "angular-cli", it is not registered!
Perhaps you are missing some plugin?
No provider for "framework:angular-cli"! (Resolving: framework:angular-cli)
Error: No provider for "framework:angular-cli"! (Resolving: framework:angular-cli)
at error (C:\xampp\htdocs\AppFineMobile\node_modules\di\lib\injector.js:22:12)
at Object.get (C:\xampp\htdocs\AppFineMobile\node_modules\di\lib\injector.js:9:13)
at Injector.get (C:\xampp\htdocs\AppFineMobile\node_modules\di\lib\injector.js:54:19)
at C:\xampp\htdocs\AppFineMobile\node_modules\karma\lib\server.js:143:20
at Array.forEach (native)
at Server._start (C:\xampp\htdocs\AppFineMobile\node_modules\karma\lib\server.js:142:21)
at Injector.invoke (C:\xampp\htdocs\AppFineMobile\node_modules\di\lib\injector.js:75:15)
at Server.start (C:\xampp\htdocs\AppFineMobile\node_modules\karma\lib\server.js:103:18)
at Promise (C:\xampp\htdocs\AppFineMobile\node_modules\@angular\cli\tasks\test.js:35:25)
at Class.run (C:\xampp\htdocs\AppFineMobile\node_modules\@angular\cli\tasks\test.js:15:16)
at Class.run (C:\xampp\htdocs\AppFineMobile\node_modules\@angular\cli\commands\test.js:99:25)
at Class.<anonymous> (C:\xampp\htdocs\AppFineMobile\node_modules\@angular\cli\ember-cli\lib\models\command.js:134:17)
at process._tickCallback (internal/process/next_tick.js:103:7)

我不明白我必须做什么。我首先运行了这个命令:

npm install --save-dev @angular/cli @types/jasmine @types/node jasmine-core jasmine-spec-reporter karma karma-chrome-launcher karma-cli karma-jasmine karma-jasmine-html-reporter karma-coverage-istanbul-reporter

它运行良好,我添加了教程中提到的所有文件......

在我的 test.ts 文件中,我的导入有一个错误:

import { getTestBed, TestBed } from '@angular/core/testing';

我有:找不到模块“@angular/core/testing”,但它存在于我的模块文件夹中...

有人有想法吗?

最佳答案

我认为你的问题是 karma.conf.js仍然指向旧的 angular-cli这已重命名为 @angular/cli

如果您将 karma.conf.js 文件中的所有 angular-cli 更改为 @angular/cli 应该指向您正确的方向。

karma.conf.js 的格式也发生了变化,因此可能需要更新。

有关更新文档,请参阅 https://github.com/angular/angular-cli/wiki/stories-rc.0-update

关于node.js - ionic 2 : Test with jasmine and karma error 'ng test' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43043428/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com