Angular-cli: A noob question sorry what is the use of spec.ts?

Created on 26 Jun 2016  路  3Comments  路  Source: angular/angular-cli

i have an issue building my project example in app.component.ts

import { Component } from '@angular/core';

@Component({
  moduleId: module.id,
  selector: 'app-root',
  templateUrl: 'app.component.html',
  styleUrls: ['app.component.css']
})
export class AppComponent {
  title = 'app works!';
}

if i remove the title = 'app works!';

ng build will fail and error output is

ng b -dev

Build failed.
The Broccoli Plugin: [BroccoliTypeScriptCompiler] failed with:
Error: Typescript found the following errors:
  /Users/DarkerThanBlack/Projects/html/ng2-admin/tmp/broccoli_type_script_compiler-input_base_path-y9aTpdto.tmp/0/src/app/app.component.spec.ts (21, 16): Property 'title' does not exist on type 'AppComponent'.
    at BroccoliTypeScriptCompiler._doIncrementalBuild (/Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:120:19)
    at BroccoliTypeScriptCompiler.build (/Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:43:10)
    at /Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/node_modules/broccoli-caching-writer/index.js:152:21
    at lib$rsvp$$internal$$tryCatch (/Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/node_modules/broccoli-caching-writer/node_modules/rsvp/dist/rsvp.js:1036:16)
    at lib$rsvp$$internal$$invokeCallback (/Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/node_modules/broccoli-caching-writer/node_modules/rsvp/dist/rsvp.js:1048:17)
    at lib$rsvp$$internal$$publish (/Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/node_modules/broccoli-caching-writer/node_modules/rsvp/dist/rsvp.js:1019:11)
    at lib$rsvp$asap$$flush (/Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/node_modules/broccoli-caching-writer/node_modules/rsvp/dist/rsvp.js:1198:9)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

The broccoli plugin was instantiated at:
    at BroccoliTypeScriptCompiler.Plugin (/Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/node_modules/broccoli-caching-writer/node_modules/broccoli-plugin/index.js:10:31)
    at BroccoliTypeScriptCompiler.CachingWriter [as constructor] (/Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/node_modules/broccoli-caching-writer/index.js:21:10)
    at BroccoliTypeScriptCompiler (/Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:27:5)
    at Angular2App._getTsTree (/Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/lib/broccoli/angular2-app.js:321:18)
    at Angular2App._buildTree (/Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/lib/broccoli/angular2-app.js:116:23)
    at new Angular2App (/Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/lib/broccoli/angular2-app.js:53:23)
    at module.exports (/Users/DarkerThanBlack/Projects/html/ng2-admin/angular-cli-build.js:10:10)
    at Class.module.exports.Task.extend.setupBroccoliBuilder (/Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/node_modules/angular-cli/lib/models/builder.js:55:19)
    at Class.module.exports.Task.extend.init (/Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/node_modules/angular-cli/lib/models/builder.js:89:10)
    at new Class (/Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/node_modules/angular-cli/node_modules/core-object/core-object.js:18:12)
    at Class.module.exports.Task.extend.run (/Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/node_modules/angular-cli/lib/tasks/build.js:15:19)
    at /Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/node_modules/angular-cli/lib/commands/build.js:32:24
    at lib$rsvp$$internal$$tryCatch (/Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/node_modules/angular-cli/node_modules/rsvp/dist/rsvp.js:1036:16)
    at lib$rsvp$$internal$$invokeCallback (/Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/node_modules/angular-cli/node_modules/rsvp/dist/rsvp.js:1048:17)
    at /Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/node_modules/angular-cli/node_modules/rsvp/dist/rsvp.js:331:11
    at lib$rsvp$asap$$flush (/Users/DarkerThanBlack/Projects/html/ng2-admin/node_modules/angular-cli/node_modules/angular-cli/node_modules/rsvp/dist/rsvp.js:1198:9)

Most helpful comment

Spec files are generated when you use angular-cli they contain your unit tests for the generated componet or service. In your case you removed sonething from the component and you have todo that alsobin your specs otherwise the project can't build

All 3 comments

Spec files are generated when you use angular-cli they contain your unit tests for the generated componet or service. In your case you removed sonething from the component and you have todo that alsobin your specs otherwise the project can't build

you can just comment out the specific test on the spec file:
// it('should have as title ...
see Test Driven Development to learn more

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NCC1701M picture NCC1701M  路  3Comments

purushottamjha picture purushottamjha  路  3Comments

JanStureNielsen picture JanStureNielsen  路  3Comments

IngvarKofoed picture IngvarKofoed  路  3Comments

jmurphzyo picture jmurphzyo  路  3Comments