intern

How to mock a Node.js module loaded with dojo/node

我的未来我决定 提交于 2019-12-23 06:05:24
问题 I have an application with the server code running on Node.js and using Dojo. I have a config module defined like: define([ 'dojo/node!nconf', 'dojo/_base/config' ], function (nconf, dojoConfig) { nconf.argv().file({ file: dojoConfig.baseDir + '/config.json' }); console.log('-- file name:', dojoConfig.baseDir + '/config.json'); console.log('-- context:', nconf.get('context')); // ... logic here ... return nconf.get(nconf.get('context')); }); To be able to unit test this module, I've written

How to require modules for testing NodeJS with Intern JS?

喜欢而已 提交于 2019-12-22 09:47:54
问题 I'm getting the error Attempt to require unloaded module xxxxxx with the following intern.js test (myfile.js below does a require('xxxxxx') ) for testing NodeJS. define(function(require) { var bdd = require('intern!bdd'); var myfile = require('../myfile.js'); bdd.describe('the thing being tested', function() { bdd.it('do the test', function() { ... The directory structure is intern.js myfile.js test |-- test.js How do I properly require a file? There's no examples on how to do it with the BDD

unknown error: failed to write prefs file

六眼飞鱼酱① 提交于 2019-12-22 04:22:15
问题 I keep getting the error while running functional tests using runner with following: -selenium 2.44 -Chrome Driver -Windows Server 2008 R2 Enterprise Error Description: Listening on 0.0.0.0:7000 Starting tunnel... UnknownError: [POST http://test.com/wd/hub/session / {"de siredCapabilities":{"browserName":"chrome","name":"tests/intern","idle-timeout": 60,"selenium-version":"2.44.0"}}] unknown error: failed to write prefs file (Driver info: chromedriver=2.12.301325

How to mock dependencies in Intern tests [closed]

╄→尐↘猪︶ㄣ 提交于 2019-12-18 09:13:14
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . Is intern use requireJs to load the test? I'm using this approach to mock out dependencies for the module I wanna test, so I wonder if this will work with Intern as well. 回答1: Intern uses the Dojo Toolkit’s AMD

How do I run functional tests in Intern against a backbone app being served up by rails?

自作多情 提交于 2019-12-13 19:33:35
问题 In all of the examples on the Intern page, a static html file is serving up some front end framework (backbone, ember, etc). So in the functional test examples, the path to the static html file is being passed to the get method. this.remote.get(require.toUrl('index.html')) In my case, the rails application is serving up the html page which hosts the backbone app. Is there a way to have intern instrument the backbone app when it is being served up by rails? The only way I've found to get the

Async test doesn't error on fail

送分小仙女□ 提交于 2019-12-13 07:07:09
问题 I'm having some trouble with getting a simple async test working. The following piece of code doesn't throw any errors in the console, even though it should, because the data passed to the function does not equal 0 : define([ 'intern!bdd', 'intern/chai!expect' ], function (bdd, expect) { with (bdd) { describe('Test', function () { it('async test', function(){ var dfd = this.async(2000); var wait = function(ms) { setTimeout(function(){ dfd.resolve('test'); }, ms); return dfd.promise; }; wait

cannot set property 'exports' of undefined

十年热恋 提交于 2019-12-13 04:49:50
问题 I have absolutely no clue why node.js makes including files from other files so difficult. I have a file called file_handler.js exports = {}; exports = { upload_file: function (fileUploaderPath, filename) { var child_process = require('intern/dojo/node!child_process'); child_process.spawn(fileUploaderPath + ' ' + filename); } }; I would expect something like var file_handler = require('./file_handler.js'); file_handler.upload_file(a,b); to work. But I'm getting an "undefined is not a function

Testing custom JavaScript (not Node module) with Intern

爱⌒轻易说出口 提交于 2019-12-12 15:05:26
问题 Is it possible to create and run test suites for custom client-side JavaScript, not created as Node modules? How should the configuration be altered then? There is loader section in the Intern configuration, specifying the packages that will be loaded, if I get it right. Is it necessary to include my custom JS code here somehow? Where shall I put my test suites and how should they look like, when they are not belonging to any Node package, only to my custom JS code, again. In other words, how

Implementing an equivalent to String.intern() for other objects

不问归期 提交于 2019-12-12 09:15:02
问题 I'm trying to implement an equivalent to String.intern(), but for other objets. My goal is the following: I've an object A which I will serialize and then deserialize. If there is another reference to A somewhere, I want the result of the deserialization to be the same reference. Here is one example of what I would expect. MyObject A = new MyObject(); A.data1 = 1; A.data2 = 2; byte[] serialized = serialize(A); A.data1 = 3; MyObject B = deserialize(serialized); // B!=A and B.data1=1, B.data2=2

how to run Intern's self-tests on mobile on SauceLabs?

烂漫一生 提交于 2019-12-12 06:40:05
问题 How do I make an Intern configuration file that runs its tests on iOS and android via SauceLabs? The selftests.intern.js file is only set to run against desktop devices. I figured out you can run against an Android simulator via: { browserName: "android", platform: "Android" } but that gets some test failures. Worse yet, I can't get iOS (any version) to work. I've tried { platform: "OS X 10.8", version: "6.1", browserName: "iPhone"} and { platform: "OS X 10.8", version: "7", browserName: