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

Update no-test-import-export rule to allow importing from anything under tests/helpers path (when using relative path) #911

Merged
merged 1 commit into from Aug 13, 2020
Merged

Conversation

bmish
Copy link
Member

@bmish bmish commented Aug 12, 2020

For example, in this test case, we can resolve the import source path to find out that it is actually a test helper being imported which is allowed:

filename: 'my-app-name/tests/helpers/foo.js'
code: "import setupApplicationTest from './setup-application-test';"

Follow-up fix for #889 #895 (comment)

CC: @raido @mongoose700

…ng under tests/helpers path when using relative path
if (importSource.endsWith('-test') && !isTestHelperImportSource(importSource)) {
if (
importSource.endsWith('-test') &&
!isTestHelperImportSource(resolve(dirname(context.getFilename()), importSource))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ember makes some of the import paths difficult to resolve, since it does things like drop the /addon or /app. I'm not sure you're able to import things from the dummy app in your tests, but if you can this might not resolve correctly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true. I'm not sure how we could handle that, but fortunately it should be very unlikely for that to affect us with test helper imports.

@bmish bmish merged commit 50bdf60 into ember-cli:master Aug 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants