Closed timofeysie closed 7 years ago
I'm away for the next week or so.
That error sounds vaguely familiar: https://github.com/lathonez/clicker/issues/153
Unfortunately the user didn't provide his solution.
I feel like it is likely down to one of the many config files or dependencies missing from your project.
I suggest getting testing working against this repo, then comparing directory structures and package.json against your project for differences.
On 5 Dec 2016 12:52, "Timothy Curchod" notifications@github.com wrote:
Hi,
I'm trying to get the code from your Unit Testing an Ionic2 project blog working. After adding all the files to the project and creating a test, I get the following when running the tests:
$ npm test
ionic-hello-world@ test /Users/timcurchod/repos/unitTestApp ng test ⠋ BuildingNo angular-cli-build.js found. Please see the transition guide: https://github.com/angular-cli/angular-cli/blob/master/TRANSITION.md#user-content-brocfile-transition. Error: No angular-cli-build.js found. Please see the transition guide: https://github.com/angular-cli/angular-cli/blob/master/TRANSITION.md#user-content-brocfile-transition. at Class.module.exports.Task.extend.setupBroccoliBuilder (/Users/timcurchod/repos/unitTestApp/node_modules/angular-cli/lib/models/builder.js:57:13) at Class.module.exports.Task.extend.init (/Users/timcurchod/repos/unitTestApp/node_modules/angular-cli/lib/models/builder.js:89:10) at new Class (/Users/timcurchod/repos/unitTestApp/node_modules/core-object/core-object.js:18:12) at Class.module.exports.Task.extend.run (/Users/timcurchod/repos/unitTestApp/node_modules/angular-cli/lib/tasks/build.js:15:19) at /Users/timcurchod/repos/unitTestApp/node_modules/angular-cli/addon/ng2/commands/test.js:63:30 at tryCatch (/Users/timcurchod/repos/unitTestApp/node_modules/rsvp/dist/rsvp.js:538:12) at invokeCallback (/Users/timcurchod/repos/unitTestApp/node_modules/rsvp/dist/rsvp.js:553:13) at /Users/timcurchod/repos/unitTestApp/node_modules/rsvp/dist/rsvp.js:628:16 at flush (/Users/timcurchod/repos/unitTestApp/node_modules/rsvp/dist/rsvp.js:2373:5) at doNTCallback0 (node.js:428:9) npm ERR! Test failed. See above for more details.
The link in that message returns a 404, and couldn't find a solution looking at similar problems.
My system info:
$ ng --version angular-cli: 0.1.0 node: 5.0.0 os: darwin x64 $ npm -v 3.3.6
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lathonez/clicker/issues/188, or mute the thread https://github.com/notifications/unsubscribe-auth/AG5tSH3BPLhgodeGJ9Q-me91lt5LdzeGks5rE6acgaJpZM4LD4Mi .
Thanks for the quick reply. I created the project from a blank tabs starter. I have added it to my GitHub here.
It seems like it's a problem with AngularCLI. This issue says: angular-cli-build.js file was removed when angular-cli migrated to webpack
, but their solution is a 17 step migration of the project source into a new project which would require quite a bit of time with this project, which mainly consists of config files.
I will follow your suggestion for using the clicker project and report back here.
Just wanted to add that with the clicker project, the unit tests run without error, but no tests are executed:
06 12 2016 08:10:50.527:WARN [karma]: No captured browser, open http://localhost:9876/
06 12 2016 08:10:50.538:INFO [karma]: Karma v1.3.0 server started at http://localhost:9876/
06 12 2016 08:10:50.538:INFO [launcher]: Launching browser Chrome with unlimited concurrency
06 12 2016 08:10:50.543:INFO [launcher]: Starting browser Chrome
06 12 2016 08:10:51.387:INFO [Chrome 55.0.2883 (Mac OS X 10.12.1)]: Connected on socket /#gwVpxe1k1iRAN1laAAAA with id 15160280
START:
Finished in 0.004 secs / 0 secs
SUMMARY:
✔ 0 tests completed
e2e tests run great. I am about to read your blog for those...
Let me know if this resolves the issue with clicker:
https://github.com/lathonez/clicker/issues/178#issuecomment-263475833
If it does I will add it to the repo.
Have since added it anyway.
Thanks for that update. Those unit tests run now.
I've been too busy to get into comparing this project with the blank starter project. Will give it a go now.
Besides the tslint.json and the addition of the mime property in the karma.conf.js file, there seems to be no difference in the project setup. Any chance you could try running my blank start (see above) project on your system and see if the unit tests will run?
Thanks for providing a repro, looking now
Looks like you're just using an old version of angular-cli. Updating it removes the error.
x220:../ionic-unit-testing$ git diff package.json
diff --git a/package.json b/package.json
index d9fa06a..6d998b6 100644
--- a/package.json
+++ b/package.json
@@ -31,7 +31,7 @@
"@ionic/app-scripts": "0.0.46",
"@types/jasmine": "^2.5.38",
"@types/node": "0.0.2",
- "angular-cli": "^0.1.0",
+ "angular-cli": "1.0.0-beta.20-1",
"codelyzer": "0.0.28",
"jasmine-core": "^2.5.2",
"karma": "^1.3.0",
You'll run into another error as you've used test.ts from this repo verbatim, you need to strip the references to clicker:
x220:../ionic-unit-testing$ git diff src/test.ts
diff --git a/src/test.ts b/src/test.ts
index 5e503a2..97efbd2 100644
--- a/src/test.ts
+++ b/src/test.ts
@@ -11,8 +11,6 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { TestBed } from '@angular/core/testing';
import { App, MenuController, NavController, Platform, Config, Keyboard, Form, IonicModule } from 'ionic-angular';
import { ConfigMock } from './mocks';
-import { ClickersServiceMock } from './services/clickers.mock';
-import { ClickersService } from './services';
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
declare var __karma__: any;
@@ -60,7 +58,6 @@ export class TestUtils {
providers: [
App, Platform, Form, Keyboard, MenuController, NavController,
{provide: Config, useClass: ConfigMock},
- {provide: ClickersService, useClass: ClickersServiceMock},
],
imports: [
FormsModule,
And then you should be fine:
x220:../ionic-unit-testing$ npm test
(node:28598) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
> ionic-hello-world@ test /home/lathonez/code/clicker_issues/ionic-unit-testing
> ng test
12 12 2016 22:00:56.506:WARN [karma]: No captured browser, open http://localhost:9876/
12 12 2016 22:00:56.523:INFO [karma]: Karma v1.3.0 server started at http://localhost:9876/
12 12 2016 22:00:56.524:INFO [launcher]: Launching browser Chrome with unlimited concurrency
12 12 2016 22:00:56.581:INFO [launcher]: Starting browser Chrome
12 12 2016 22:00:57.792:INFO [Chrome 54.0.2840 (Linux 0.0.0)]: Connected on socket /#p55mAS9sAo_SgfVrAAAA with id 60355744
START:
Pages: Home
✔ should create the home page
Finished in 0.732 secs / 0.725 secs
SUMMARY:
✔ 1 test completed
Thanks. I see. I thought the ^ would update to the latest version, but it only matches the most recent minor version, so it would not match 1.0. Are you going to update your post with this step? I see also that the ClickersService and ClickersServiceMock are still referenced in the test.ts file.
Are you going to update your post with this step
Where in the post does it say to use ^0.1.0
?
I see also that the ClickersService and ClickersServiceMock are still referenced in the test.ts file.
Hi,
I'm trying to get the code from your Unit Testing an Ionic2 project blog working. After adding all the files to the project and creating a test, I get the following when running the tests:
The link in that message returns a 404, and couldn't find a solution looking at similar problems.
My system info: