Stencil: Stencil generate: generated Spec Test .spec.tsx file with import component path

Created on 27 Apr 2020  ·  3Comments  ·  Source: ionic-team/stencil

Stencil version:

 @stencil/core@@1.12.6

I'm submitting a:
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior:
stencil generate test-comp with Spec Test enabled as follow

? Which additional files do you want to generate? ›  
Instructions:
    ↑/↓: Highlight option
    ←/→/[space]: Toggle selection
    a: Toggle all
    enter/return: Complete answer
◉   Stylesheet (.css)
◉   Spec Test  (.spec.tsx)
◉   E2E Test (.e2e.ts)

will generate in src/components/test-component/test directory the test-comp.spec.tsx file with the following import statement:

import { TestComponent } from './mt-image';

Expected behavior:
It should be:

import { TestComponent } from '../mt-image'; // NOTE THE .. instead of .

Culprit:

In the file src/cli/tasks/task-generate.ts, the method getSpecTestBoilerplate has the following line:

import { ${toPascalCase(tagName)} } from './${tagName}';

It should be:

import { ${toPascalCase(tagName)} } from '../${tagName}';
triage

Most helpful comment

For the love of god, dear stencil team. Stop breaking generate! This is a massive issue for existing code bases with loads of components that all need to be refactored to the new way of generate every time you change it, and you keep changing (and breaking!!!) it without ANY community communication! At least do the changes to generate in one fell swoop so we don't have to continually refactor all existing components! And document them in the changenotes!

All 3 comments

For the love of god, dear stencil team. Stop breaking generate! This is a massive issue for existing code bases with loads of components that all need to be refactored to the new way of generate every time you change it, and you keep changing (and breaking!!!) it without ANY community communication! At least do the changes to generate in one fell swoop so we don't have to continually refactor all existing components! And document them in the changenotes!

@alexandertrefz is right. It would be nice a feature like Angular Schematics.

The import was fixed in #2486

Was this page helpful?
0 / 5 - 0 ratings