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

js helpers not loading from the correct location #15

Closed
lorennorman opened this issue Apr 7, 2015 · 4 comments
Closed

js helpers not loading from the correct location #15

lorennorman opened this issue Apr 7, 2015 · 4 comments

Comments

@lorennorman
Copy link
Contributor

I have this directory structure:
2015-04-07 at 2 09 pm

...and this is my cypress.json:

{
  "cypress": {
    ...
    "testFolder": "spec/cypress",
    "javascripts": ["support/spec_helper.coffee"]
  }
}

That javascripts line makes it hit this URL:
http://localhost:3000/support/spec_helper.coffee

...which 404s. I think it is supposed to be hitting this one:
http://localhost:3000/tests/support/spec_helper.coffee

(if I change the line to "javascripts": ["tests/support/spec_helper.coffee"] then it works, but obviously that's not what I should be doing)

Looks like a find/replace error where you removed tests from one place you shouldn't have, maybe? Or didn't finish changing away from tests to the json-injected location.

Thanks! ✨

@brian-mann
Copy link
Member

Okay yah, javascripts paths are always relative to your projectRoot directory. I can certainly see how you'd assume it to be relative to your testFolder. The idea was that javascripts may contain other files besides support files, or files within the testFolder itself.

But that may be the minority scenario, and if so I'd gladly change this to be relative to testFolder.

Alternatively, this is all part of configuration, which I intend to build a GUI for which can intelligently diagnose your settings and figure out whether it can even find files at those paths. Then the implementation details aren't nearly as important.

@lorennorman
Copy link
Contributor Author

Actually, root-relative is where I started, and that would be:
spec/cypress/support/spec_helper.coffee
...which does not work.

Again, it only works when I pull tests out of the sky (there is no folder named tests in my project at this time.)

@brian-mann
Copy link
Member

Okay this is fixed in 0.4.1. Changelog

javascripts are now correctly assumed to be a path from the root of your project.

You'll need to change the paths in your javascripts array to read: spec/cypress/support/spec_helper.coffee

They are now preprocessed in the same way as your spec files, which means they naturally support snockets, browserify, or requirejs.

Previously this didn't work because but it wasn't pre-processing the file. Therefore it was sending raw coffeescript.

Prepending the tests actually tricked Cypress into thinking it was an actual spec file and assuming it could be found from within your testFolder and preprocessing it. Obviously that is super weird and not supported. And it just worked because your support file happened to be in the testFolder.

I've changed the url strategy to prevent that now.

I also realized I'm not currently supporting globbing in the javascripts array, but I will add that in the next few days.

@lorennorman
Copy link
Contributor Author

👍 super thanks

On Wednesday, April 8, 2015, Brian Mann [email protected] wrote:

Closed #15 #15.


Reply to this email directly or view it on GitHub
#15 (comment).

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Dec 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants