You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 26, 2020. It is now read-only.
require() does not work in lotte tests. It would be awesome if we could require() our own modules though. In my tests, I usually startup my web server right in the test code, then inject dependencies in the web server and then I mock the desired behavior according to each test.
For example:
@base'http://localhost:10000'@title'Foo bar'
{WebServer} =require'../webserver'classEmptyApp_searchResult: []
searchStuff: (terms) ->return _searchResult;
app=newEmptyAppnewWebServer(10000, app).start=>@open'/', ->@describe'Search test', ->app._searchResult= ['foo', 'bar']
# do a search, submit the form, assert things, etc@success()
The text was updated successfully, but these errors were encountered:
I have been using a custom Lottefile function for a while now which does Sprocket-style requires. I haven't been able to make it work inside PhantomJS but happy to pull any patches 😄
// [..]on('compile',function(args,options,resume){'use strict';args.code=args.code.replace(/^\s*\/\/=\s*require\s+(["<])([^">]+).$/mg,function(match,type,location){vardirectory;// Absolute require from current working directory.if(type==='<'){directory='[require("fs").workingDirectory]';// Relative require from current executing file.}else{// ${FILE} is a special marker which is substituted with the absolute// path to the current executing file. By splitting its path components// and removing the last one, we retrieve only the directory.directory='${FILE:encode}.split(/[\\/\\\\]/).slice(0, -1)';}return'phantom.injectJs('+directory+'.concat('+JSON.stringify((location.replace(/\.js$/,'')+'.js').split(/[\/\\]/))+').join(require("fs").separator));';});resume();});
require()
does not work in lotte tests. It would be awesome if we couldrequire()
our own modules though. In my tests, I usually startup my web server right in the test code, then inject dependencies in the web server and then I mock the desired behavior according to each test.For example:
The text was updated successfully, but these errors were encountered: