Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jest refuses to accept "./login.component' import inside immediate directory #1697

Open
nhhockeyplayer opened this issue Jul 19, 2022 · 3 comments

Comments

@nhhockeyplayer
Copy link

nhhockeyplayer commented Jul 19, 2022

Version

27.5.1

Steps to reproduce

this occurs to all spec files in codebase that attempt to operate on their local files in their local directory

import { LoginComponent } from './login.component';

so fundamental
and cant do it

have to operate the path in tsconfig taking the scenic route thru the tsconfig path and barrel file
import {LoginComponent} from '@meanstacknh/shared-feature-auth'
which may not even be valid I feel

Expected behavior

should be able to import right on the immediate operating working directory

this is widespread impact to large codebases and not fun consuming alot of time to re-work

Actual behavior

nx run shared-feature-auth:test

 FAIL   shared-feature-auth  libs/shared/feature/auth/src/lib/components/login/login.component.spec.ts
  ● Test suite failed to run

    ReferenceError: TextEncoder is not defined

    > 1 | import {
        | ^
      2 |     DocumentType,
      3 |     getModelForClass,
      4 |     modelOptions,

Additional context

immediate relative imports are safe imports preventing unnecessary parsing searching thru paths and barrel files and take precedence to avoid circular dependencies

and this error is forcing us to do the latter with unknown forecasted ramifications

please prioritize immediate relative imports

Environment

nx report

 >  NX   Report complete - copy this into the issue template

   Node : 16.15.1
   OS   : darwin x64
   yarn : 1.22.18
   
   nx : 14.4.3
   @nrwl/angular : 14.4.3
   @nrwl/cypress : 14.4.3
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.4.3
   @nrwl/eslint-plugin-nx : 14.4.3
   @nrwl/express : 14.4.3
   @nrwl/jest : 14.4.3
   @nrwl/js : 14.4.3
   @nrwl/linter : 14.4.3
   @nrwl/nest : 14.4.3
   @nrwl/next : Not Found
   @nrwl/node : 14.4.3
   @nrwl/nx-cloud : 14.2.0
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/schematics : 8.12.11
   @nrwl/storybook : 14.4.3
   @nrwl/web : 14.4.3
   @nrwl/workspace : 14.4.3
   typescript : 4.7.4
   ---------------------------------------
   Community plugins:
   	 @fortawesome/angular-fontawesome: 0.11.1
   	 @ionic/angular: 6.1.14
   	 @ngrx/component: 14.0.2
   	 @ngrx/component-store: 14.0.2
   	 @ngrx/effects: 14.0.2
   	 @ngrx/entity: 14.0.2
   	 @ngrx/router-store: 14.0.2
   	 @ngrx/store: 14.0.2
   	 @nxtend/capacitor: 13.0.0
   	 @nxtend/ionic-angular: 13.1.0
   	 @storybook/angular: 6.5.9
   	 angular-builder-custom-terser-options: 1.0.1
   	 @compodoc/compodoc: 1.1.19
   	 @ngrx/schematics: 14.0.2
   	 @ngrx/store-devtools: 14.0.2
   	 ngx-build-plus: 14.0.0
@ahnpnl
Copy link
Collaborator

ahnpnl commented Jul 19, 2022

Please provide your reproduce scenario with https://github.com/thymikee/jest-preset-angular/tree/main/examples

@ahnpnl
Copy link
Collaborator

ahnpnl commented Jul 21, 2022

Sure that also works for me

@nhhockeyplayer
Copy link
Author

nhhockeyplayer commented Jul 22, 2022

Sure that also works for me

Okay your all set
just run the following after clone

https://github.com/nhhockeyplayer/meanstacknh


- yarn install
- nx build shared-feature-auth
- nx run shared-feature-auth:test

the general issue... imports are a general problem for TEST locally and outside the module.
when none of this should be happening the main build runs and completes fine
lso, I sense somewhere someone is inducing the usage of the package.json "type": "module" somewhere possibly within the mix and jarring other build tasks and configurations...

looking forward to your feedback

this repo is a good unit test

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants