3

Im really stuck now with the play framework and the jasmine plugin made by the guardian newspaper, https://github.com/guardian/sbt-jasmine-plugin.

I have gotten jasmine to run with play test, but i get issues because of require.

Cases:

  1. Trying to load my app or other modules I want to test in test.dependencies.js. This results in error MISMATCHED ANONYMOUS DEFINE() MODULES. All my js files are wrapped in define. This means that it all crashes and the test is never run.

  2. Trying to call define around the describe to call on my modules I want to test in the current specc. This results in error was: InternalError: Couldn't read source file "./test.js: ./test.js (No such file or directory)". (rjs/r-2.0.1.js#2114). Its really hard to see where it want to try to load from. But its r-2.0.1.js which creates this error.

  3. Im trying to call require() on the curent js file I want to test,file is called test right now. This results in error was: Error: Module name "test" has not been loaded yet for context: _. Not sure what I should do.

  4. Im trying to call require on the current js file, but in absolut path, I want to test. This results in that it works. BUT only if I write something in the function variables. This can be whatever. If I remove the variable in the function call in define(function(variable) {...}) it results in error was: Error: Module name "test" has not been loaded yet for context: _.

  5. Trying to require just test, file name is test.js. This results in error was: InternalError: Couldn't read source file "./test.js: ./test.js (No such file or directory)". (rjs/r-2.0.1.js#2114) Same weird thing here when a random variable is with or not.

  6. Trying to require with a variable for the absolute path, so I just have to put it one place. This results in Error: Module name "path..../test.js" has not been loaded yet for context: _ Meaning that the absolute path is there, but for some reason I get the not loaded. I can even console log the variable before trying to require, and its correct.

The weird thing cannot be resolved with defining an empty list in define. But only with a variable in the function. Unless I actually define something in the define array.

Hope someone have some insight into this. I am really lost.

4

1 回答 1

0

监护人已被弃用。新的仓库位于https://github.com/joescii/sbt-jasmine-plugin

你试过那个吗?


编辑:

为此,我还构建了自己的插件:https ://github.com/tanin47/sbt-web-test-js

与 sbt-jasmine-plugin 的区别在于:

  1. 测试人员可以在 Coffeescripts
  2. 它使用 PhantomJS 来执行测试 HTML 文件。sbt-jasmine-plugin 使用 env-js + Rhino,在我看来,它不太健壮。
于 2015-09-14T10:46:26.907 回答