-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Cannot find module in e2e-specs when importing local library #263
Comments
@vsavkin I would like to know how to properly organize the structure of common e2e tests(for *.po.ts and *.e2e-spec.ts both together and separately) |
The errors says "E/launcher - Error: Error: Cannot find module '@content-platform/test-helpers'", but the library name is "e2e-test-helpers". Should not you import: |
@vsavkin my bad we also have a different library called (unit) test-helpers, so I was testing it with that as well seeing if it was a naming thing, this is the actual (same) error:
To make it work currently I directly referenced the library like so:
|
Closing as will not fix. |
:( relative path very ugly |
... very old but I came across this too, and fixed this just recently in a workspace where I re-use things from an e2e helper lib. the thing is, the protractor e2e tests are executed using ts-node. ts-node does not recoginze the path mappings, that is why you need to use relative paths - but there is a node package called tsconfig-paths that can add this feature to ts-node executions. see #294 of ts-node ... if you need details of how to set this up with nx just let me know, I can share my setup using tsconfig-paths with protractor ... |
@skydever actually today I came same problem - could you share you config for tsconfig-paths with protractor ? |
@skydever I found it , thanks :) |
@skydever can you share your config please |
@jhua4 I did it like this:
require('tsconfig-paths').register({
project: require('path').join(__dirname, './tsconfig.e2e.json'),
baseUrl: './',
paths: tsConfig.compilerOptions.paths
}); I did a require for the main const tsConfig = require('../../tsconfig.json'); I think that did the trick. Just ping me if you have any problems (I switched to Cypress, so I am not sure if this is up to date, but I guess so...). |
@skydever Can you post how you got this to work with Cypress? |
hi @jbarrus I do not use paths with cypress at the moment 🤔 maybe this helps for further analysis (not sure when I have the time). My setup looks like this (#883 seems related, wanted to link it):
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"types": ["cypress", "node"]
},
"include": ["**/*.ts"]
}
{
"fileServerFolder": "../../dist/out-tsc/apps/my-app-e2e",
"fixturesFolder": "../../dist/out-tsc/apps/my-app-e2e/src/fixtures",
"integrationFolder": "../../dist/out-tsc/apps/my-app-e2e/src/integration",
"pluginsFile": "../../dist/out-tsc/apps/my-app-e2e/src/plugins/index.js",
"supportFile": false,
"video": false,
"videosFolder": "../../dist/out-tsc/apps/my-app-e2e/videos",
"screenshotsFolder": "../../dist/out-tsc/apps/my-app-e2e/screenshots"
}
import {
something,
anotherThing
} from '../../../../libs/e2e-cypress-helper/src';
{
"extends": "./tsconfig.json",
"compilerOptions": {
"sourceMap": false,
"outDir": "../../dist/out-tsc",
"lib": ["es2015", "dom"],
"types": ["cypress", "node"]
},
"include": ["src/**/*.ts", "../../node_modules/cypress"]
} ... and this is working at my side. Maybe it helps to be able to use path mappings, would be awesome! does this work for you too (without paths) or do you have another solution? |
related to #1238 |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Hi, I have a library that contains some overlapping e2e logic used across multiple apps, when I try to import the library into the e2e spec, I get this error when running the e2e tests:
Cli info:
E2E tsconfig:
Main Tsconfig:
The text was updated successfully, but these errors were encountered: