Closed RGreinacher closed 8 years ago
I filed the issue using teaspoon-mocha. Today I tried to use teaspoon-jasmine and I still get the same error. Via CLI I tried to call Teaspoon.hook('test_hook')
in my _testspec.coffee and got the following:
ReferenceError: Can't find variable: url
# teaspoon-jasmine2.self-193432e902b3943f7e511bf7ba322e1ce098119d180978aaff50918567da9361.js:456
# :0 -- send
# teaspoon-jasmine2.self-193432e902b3943f7e511bf7ba322e1ce098119d180978aaff50918567da9361.js:447 -- xhrRequest
# teaspoon-jasmine2.self-193432e902b3943f7e511bf7ba322e1ce098119d180978aaff50918567da9361.js:451 -- hook
# support/annotation_document_manager_spec.self-3b741f4f9c671769efb6d88a542bc1349a97c04e75257ef128be885deaa25d67.js:3
# jasmine/2.3.4.self-aa35a2d6ef4c597846860937831b786d7a7b61cf7b7d860a06b484aa1b637276.js:1790 -- attemptSync
# jasmine/2.3.4.self-aa35a2d6ef4c597846860937831b786d7a7b61cf7b7d860a06b484aa1b637276.js:1778 -- run
# jasmine/2.3.4.self-aa35a2d6ef4c597846860937831b786d7a7b61cf7b7d860a06b484aa1b637276.js:1763 -- execute
# jasmine/2.3.4.self-aa35a2d6ef4c597846860937831b786d7a7b61cf7b7d860a06b484aa1b637276.js:628 -- queueRunnerFactory
# jasmine/2.3.4.self-aa35a2d6ef4c597846860937831b786d7a7b61cf7b7d860a06b484aa1b637276.js:2210 -- execute
# jasmine/2.3.4.self-aa35a2d6ef4c597846860937831b786d7a7b61cf7b7d860a06b484aa1b637276.js:679 -- execute
# teaspoon-jasmine2.self-193432e902b3943f7e511bf7ba322e1ce098119d180978aaff50918567da9361.js:1462 -- Runner
# teaspoon-jasmine2.self-193432e902b3943f7e511bf7ba322e1ce098119d180978aaff50918567da9361.js:35 -- execute
# teaspoon-jasmine2.self-193432e902b3943f7e511bf7ba322e1ce098119d180978aaff50918567da9361.js:49 -- onload
for the following hook:
suite.hook :test_hook do
ap 'wow, such test!'
end
Interesting thing is that I nevertheless got the console output "wow, such test!" - so the hook is working, but throwing an error anyways.
Yeah, I get this same error... I'm trying to dive into it today. Its all working as expected but throws a TON of errors when i'm running my test suite. We've been just living with it for about 2 months now. 🐻
so, it looks like this:
https://github.com/modeset/teaspoon/blob/master/app/assets/javascripts/teaspoon/hook.coffee#L22
That will let you know (and will in theory break a test) if the response isn't a 200.. but it's using a variable that's not defined url
.
I'll try and get to this today.
I solved my case. I will have a PR open when i get back from lunch.
:success
is not a valid status code symbol so the server always returns 500.
ah, yes.. it's :ok, not :success.
but the underlying problem is still there with the url variable.
@jejacks0n, I'm thining about not relying on the url
variable, but returning an error message from the server with a :not_found - 404
status code if there is no hook present (exactly what the hook.coffee throw was trying to show).
def hook
hooks = Teaspoon::Suite.new(params).hooks[params[:hook].to_s]
if hooks.present?
hooks.each { |hook| hook.call(hook_params(params[:args])) }
head(:ok)
else
render status: :not_found, json: {err: "The `#{params[:hook].to_s}` hook is not defined in the `#{params[:suite].to_s}` suite "}
end
end
Then just render that err from the response in the throw. If you agree i'll open up a PR.
Working error output.
Hey!
I try to create a hook like so:
(_teaspoonenv.rb, in
config.suite do |suite|
)and call it in my _my_testspec.coffee with
This leads me to the following error in both, browser and CLI:
What am I doing wrong? Thanks a lot! : )