javascript 你如何在浏览器中运行 Jasmine 测试?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28686015/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 09:22:21  来源:igfitidea点击:

How do you run Jasmine tests in the browser?

javascriptnode.jsjasmine

提问by Adam Zerner

I'm using jasmine-npm. jasmine-initsets it up such that you could run jasminein the terminal to test your code.

我正在使用jasmine-npmjasmine-init设置它以便您可以jasmine在终端中运行以测试您的代码。

I recall seeing these tests in the browser before and would like to see them there. How would I run the tests in the browser? (This seems like this should be something that's easy to research, but I swear that I've spent over 2 hours researching this and can't figure it out).

我记得以前在浏览器中看到过这些测试,并希望在那里看到它们。我将如何在浏览器中运行测试?(这看起来应该是很容易研究的东西,但我发誓我已经花了 2 个多小时研究这个并且无法弄清楚)。

采纳答案by Adam Zerner

Option 1:

选项1:

JASMINE STANDALONE

Included is a sample app and sample tests. Open SpecRunner.html and run the included specs. Both the source files and their respective specs are linked in the of the SpecRunner.html.

To start using Jasmine, replace the source/spec files with your own.

Load the SpecRunner.html in your favorite browser

https://jasmine.github.io/pages/getting_started.html

茉莉花单机版

包括一个示例应用程序和示例测试。打开 SpecRunner.html 并运行包含的规范。源文件及其各自的规范都链接在 SpecRunner.html 的 中。

要开始使用 Jasmine,请将源/规范文件替换为您自己的。

在您喜欢的浏览器中加载 SpecRunner.html

https://jasmine.github.io/pages/getting_started.html

Option 2: https://github.com/airportyh/testem.

选项 2:https: //github.com/airportyh/testem