lathonez / clicker

Ionic 2 + @angular/cli Seed Project : Angular2 + Typescript + Karma + Protractor + Travis
http://lathonez.com/2018/ionic-2-unit-testing/
MIT License
430 stars 136 forks source link

Can't resolve 'hello-ionic.html' #197

Closed fizdalf closed 7 years ago

fizdalf commented 7 years ago

I follow your guide, except I have Ionic 2 RC4, and karma is running, but it cannot resolve the html files.

ERROR in ./src/pages/hello-ionic/hello-ionic.ts Module not found: Error: Can't resolve 'hello-ionic.html' in 'E:\proyectos\Pavillion Web\BrightonAndHove\app2\src\pages\hello-ionic' @ ./src/pages/hello-ionic/hello-ionic.ts 9:2738-2765 @ ./src/pages/hello-ionic/hello-ionic.spec.ts @ ./src .spec.ts @ ./src/test.ts

I'm using the Ionic 2 tutorial template created with "ionic folder tutorial --v2", and the test file I created is as follows:

import {ComponentFixture, async} from "@angular/core/testing"; import {HelloIonicPage} from "./hello-ionic"; import {TestUtils} from "../../test";

let fixture: ComponentFixture = null; let instance: any = null;

describe('Pages: HelloIconic', () => { beforeEach(async(() => TestUtils.beforeEachCompiler([HelloIonicPage]).then(compiled => { fixture = compiled.fixture; instance = compiled.instance; })));

it('should create the hello ionic page', async(() => { expect(instance).toBeTruthy(); })); });

sf1234 commented 7 years ago

I am also getting exact same error.

lathonez commented 7 years ago

OK, guess we need to update for RC4. We do accept pull requests!

On 16 Dec 2016 23:44, "sf1234" notifications@github.com wrote:

I am also getting exact same error.

— 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/197#issuecomment-267723150, or mute the thread https://github.com/notifications/unsubscribe-auth/AG5tSFrcDXW1eFwYv9ixurNSI-2dQwwXks5rIyJcgaJpZM4LPhcE .

lathonez commented 7 years ago

I've made a start on upgrading to rc4 and ng-cli 22-1. Ionic have broken the tutorial project that clicker was initially forked from which is making things slow going.

lathonez commented 7 years ago

Have replicated this mid rc4 upgrade

lathonez commented 7 years ago
ERROR in ./src/pages/clickerList/clickerList.ts
Module not found: Error: Can't resolve 'clickerList.html' in '/home/lathonez/code/clicker/src/pages/clickerList'
 @ ./src/pages/clickerList/clickerList.ts 9:3132-3159
 @ ./src/pages/index.ts
 @ ./src/app/app.component.ts
 @ ./src/app/app.spec.ts
 @ ./src \.spec\.ts
 @ ./src/test.ts
lathonez commented 7 years ago

The template urls need the current working directory added into the path.

For example:

  templateUrl: 'hello-ionic.html',

becomes

  templateUrl: './hello-ionic.html',

This must have been a change in ng-cli, seems to be this: https://github.com/angular/angular-cli/commit/27a034d

lathonez commented 7 years ago

https://github.com/angular/angular-cli/issues/3497#issuecomment-266089480

lathonez commented 7 years ago

Had a look for a way around this and seems there isn't one.