静态非静态加载
I use Intern by SitePen for all of my JavaScript functional testing. Intern has loads of features other functional test frameworks don't and it's completely Promise-based -- something I got very used to when I used the Dojo Toolkit every day. Async test creation can be difficult but I find it very rewarding.
我使用SitePen的Intern进行所有JavaScript功能测试。 实习生拥有许多其他功能测试框架所没有的功能,并且完全基于Promise -当我每天使用Dojo Toolkit时,我已经很习惯了。 异步测试的创建可能很困难,但我发现它非常有意义。
While writing destructive tests for the Mozilla Developer Network, I decided I wanted to load specific content to test. The first step is adding a new file with the sample content alongside my tests, but then I needed to know how to load that content alongside the other test dependencies. Since that file isn't a JavaScript object, we need to pull that dependency in a special way:
在为Mozilla开发人员网络编写破坏性测试时,我决定要加载特定的内容进行测试。 第一步是添加一个带有示例内容以及测试的新文件,但是随后我需要知道如何与其他测试依赖项一起加载该内容。 由于该文件不是JavaScript对象,因此我们需要以特殊方式提取该依赖关系:
define([ 'intern!object', 'intern/chai!assert', 'intern/dojo/text!tests/fixtures/in-content.html' ], function(registerSuite, assert, contentTemplate) { // Use the contentTemplate string here... });Adding intern/dojo/text! before the file path allows the file to be loaded without being evaluated as JavaScript. You can prepend that string to load any file type and use it as text in the callback!
添加intern/dojo/text! 文件路径允许在不评估JavaScript的情况下加载文件。 您可以在字符串前添加任何文件类型,并将其用作回调中的文本!
翻译自: https://davidwalsh.name/loading-static-template-intern-testing
静态非静态加载