找不到描述打字稿Angular

时间:2018-04-23 13:14:59

标签: angular typescript ionic-framework jasmine karma-jasmine

我试着用茉莉和业力测试,但我总是有问题。我尝试了一切,但问题相同。

我尝试了一个简单的例子来测试它是否正常工作。 app.component.spec.ts

    import {} from 'jasmine';
    import {MyApp } from './app.component';

     describe('MyApp',()=>{ 
      it('true should be true',()=> { 
      expect(1+1).toBe(2);
     })

    })

的package.json

  {
  "name": "app",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
 "scripts": {
  "clean": "ionic-app-scripts clean",
  "build": "ionic-app-scripts build",
  "lint": "ionic-app-scripts lint",
  "ionic:build": "ionic-app-scripts build",
  "ionic:serve": "ionic-app-scripts serve"
 },
 "dependencies": {
  "@angular/common": "5.0.1",
  "@angular/compiler": "5.0.1",
   "@angular/compiler-cli": "5.0.1",
   "@angular/core": "5.0.1",
   "@angular/forms": "5.0.1",
   "@angular/http": "5.0.1",
   "@angular/platform-browser": "5.0.1",
   "@angular/platform-browser-dynamic": "5.0.1",
   "@ionic-native/core": "4.4.0",
   "@ionic-native/splash-screen": "4.4.0",
   "@ionic-native/status-bar": "4.4.0",
   "@ionic/storage": "2.1.3",
   "cordova-android": "^7.1.0",
   "cordova-ios": "4.5.4",
   "ionic-angular": "3.9.2",
   "ionicons": "3.0.0",
   "jasmine": "^3.1.0",
   "moment": "^2.22.1",
   "optional": "^0.1.4",
   "platform": "1.3.5",
    "rxjs": "^5.5.10",
    "sw-toolbox": "3.6.0",
     "zone.js": "0.8.18"
  },
 "devDependencies": {
  "@ionic/app-scripts": "3.1.2",
  "@types/jasmine": "^2.8.6",
  "@types/node": "^9.6.6",
  "angular2-template-loader": "^0.6.2",
  "html-loader": "^0.5.5",
  "istanbul-instrumenter-loader": "^3.0.1",
  "jasmine-core": "^2.99.1",
  "jasmine-spec-reporter": "^4.2.1", 
  "karma": "^2.0.0",
  "karma-chrome-launcher": "^2.2.0",
  "karma-cli": "^1.0.1",
  "karma-coverage-istanbul-reporter": "^1.4.2",
  "karma-jasmine": "^1.1.1",
  "karma-jasmine-html-reporter": "^1.0.0",
   "karma-typescript": "3.0.12",
   "protractor": "^5.3.1",
   "ts-node": "^6.0.0",
  "typescript": "^2.8.3"
  },
 "description": "An Ionic project",
 "main": "karma.conf.js",
 "directories": {
  "lib": "lib"
 },
 "license": "ISC"
}

tsconfig.json

 {
 "compilerOptions": {
 "allowSyntheticDefaultImports": true,
 "declaration": false,
  "emitDecoratorMetadata": true,
  "experimentalDecorators": true,
  "lib": [
   "dom",
   "es2015"
  ],

"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"target": "es5",
"typeRoots": [
  "../node_modules/@types"
 ]
},
  "include": [
  "src/**/*.ts"
],
 "exclude": [
  "node_modules",
  "src/**/*.spec.ts",
   "src/**/__tests__/*.ts"
  ],
 "compileOnSave": false,
 "atom": {
  "rewriteTsconfig": false
 },
"types": [
 "jasmine"
 ]
}

karma.conf.js

 module.exports = function(config) {
 config.set({
 basePath: '',
frameworks: ['jasmine'],
files: [
],
 exclude: [
],
preprocessors: {
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,

autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
concurrency: Infinity
})
 }

我认为这是错误:

 3 04 2018 15:07:49.397:ERROR [config]: Invalid config file!
 TSError: ⨯ Unable to compile TypeScript
 src\app\app.component.spec.ts (2,1): Cannot find name 'describe'. (2304)
 src\app\app.component.spec.ts (3,5): Cannot find name 'it'. (2304)
  src\app\app.component.spec.ts (4,9): Cannot find name 'expect'. (2304)

我尝试了我发现的所有内容,但我总是遇到同样的问题。

0 个答案:

没有答案