ngneat / spectator

🦊 🚀 A Powerful Tool to Simplify Your Angular Tests
https://ngneat.github.io/spectator
MIT License
2.07k stars 178 forks source link

Component schematics produces test file in different directory #611

Open MikeDabrowski opened 1 year ago

MikeDabrowski commented 1 year ago

Is this a regression?

No

Description

Is it intended that running ng g @ngneat/spectator:spectator-component test-help produces:

image

with the test file being in a different directory? The following line does that: https://github.com/ngneat/spectator/blob/5320a1963b784001743723fb397463892c3dfc68/projects/spectator/schematics/src/spectator/index.ts#L33

When executing the options.path points to /src/app and if options.flat is true then movePath becomes /src/app/test-help.

If it is intended - how to opt-out and follow the same convention as angular has? If it is NOT intended - one way to fix this would be to copy the path generating mechanism from angular schematics.

Do you want to create a pull request?

Yes

screambeard commented 11 months ago

i'm facing the same issue since a couple of weeks

Sk0vgaard commented 10 months ago

Facing same issue... In generel it is always adding the .spec file to the app folder for some reason.

Its seems like it only applies for the @ngneat/spactator:spectator-(component/directive, etc), where "jest" has been set to true:

    "@ngneat/spectator:spectator-component": {
      "jest": true
    },

Could it be because of Angular 15+?

Edit: I have now tried to roll back to v14 from v16 and it seems to work with earlier versions... I rolled back using angular v14.2.10 and "@ngneat/spectator": "^12.0.1",

JabCorp commented 9 months ago

Facing same issue but it's not only when jest parameter is set to true.

WillBoig commented 7 months ago

I have the same issue and I'm not using jest

JabCorp commented 7 months ago

Some workaround

    "@ngneat/spectator:spectator-component": {
      "jest": true,
      "flat": false
    },
WillBoig commented 2 months ago

This problem applies to every schema that I have tested so far (directive, component, pipe, service). I'm willing to help out and I know where to look for a fix but so far I'm unable to produce a clean solution.

Tested on the latest release of spectator