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

Error running tests #10

Closed
JarrodCTaylor opened this issue Jul 7, 2015 · 5 comments
Closed

Error running tests #10

JarrodCTaylor opened this issue Jul 7, 2015 · 5 comments

Comments

@JarrodCTaylor
Copy link

I am unable to successfully include the storage-atom library in my reagent project. When the local-storage function is in the application I receive the following error when attempting to run the tests.

Running ClojureScript test: unit
SECURITY_ERR: DOM Exception 18: An attempt was made to break through the security policy of the user agent.

  target/test.js:59967 in alandipert$storage_atom$local_storage
  target/test.js:63470

ERROR: cemerick.cljs.test was not required.

You can resolve this issue by ensuring [cemerick.cljs.test] appears
in the :require clause of your test suite namespaces.
Also make sure that your build has actually included any test files.

Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL file:///var/folders/9c/69bx15w13fn_vfdt_xr5tthc0000gn/T/runner1566161236994641740.js. Domains, protocols and ports must match.

Subprocess failed

This can be recreated by creating a reagent project from the template
lein new reagent local-storage-error +test

The tests can be run successfuly at this point.
lein cljsbuild test

Add the storage-atom lib to the project and include it in core.cljs and create the def from the readme
(def prefs (local-storage (atom {}) :prefs))

Now attempting to run the tests again will produce the error from above.

@Frozenlock
Copy link
Collaborator

My guess is that you are testing with phantom.js or something like it.

These testing tools do not support things like local-storage. You'd need a browser for that.
(At least that was my conclusion after wasting 10 hours on the subject a few months ago.)

@JarrodCTaylor
Copy link
Author

@Frozenlock you are correct on both the assumption that I was using Phantom and that attempting to access localStorage in Phantom does seem to cause an issue. How do the tests for this library work given that they run with Phantom?

What did you end up using other than Phantom, and do you perhaps have an example of wiring something else up for tests with reagent?

@Frozenlock
Copy link
Collaborator

While not the most elegant, I mostly use the same technique as the one used for the Reagent projects.
(Tested directly in the browser.)

See this example: https://github.com/reagent-project/reagent-cursor/tree/master/test

@JarrodCTaylor
Copy link
Author

@Frozenlock wanted to let you know that the issue was not with Phantom but with clojurescript.test see this issue for reference. It has been fixed in version 0.3.3 after an update tests ran as expected with Phantom.

@Frozenlock
Copy link
Collaborator

@JarrodCTaylor

Nice, thanks for the heads up!

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

No branches or pull requests

3 participants
@Frozenlock @JarrodCTaylor and others