Questions tagged [squirejs]

Squire.js is a dependency injector for Require.js users to make mocking dependencies easy!

12 questions
20
votes
1 answer

Squire.js example with Jasmine and RequireJS

I want to write JS tests. The production code is written with RequireJS. I found a test lib named Squire.js: https://github.com/iammerrick/Squire.js/ From the Squire.js website Run generates a function that will receive a done callback and execute…
Androidewbie
  • 345
  • 3
  • 14
8
votes
2 answers

Squire is breaking other tests

I'm using Karma, Jasmine, Jasmine.Async, Sinon and Chai. The good news...this test works correctly. The dependency is mocked, spies get called, and intentionally breaking the test subject results in failed tests. define(['chai', 'squire'], function…
Dom Barker
  • 1,889
  • 1
  • 16
  • 29
5
votes
1 answer

Squire.js not substituting fake dependency when using store

I'm trying out Squire.js as a dependency loader for RequireJS. Using a totally normal web browser for running unit tests. I want to use store to get a handle to my mocks. But can't stop Squire loading the actual module. mock works…
sennett
  • 8,014
  • 9
  • 46
  • 69
4
votes
1 answer

Squirejs causing random tests to intermittently fail or not run at all

We're using Karma and Mocha along with Squire for mocking dependencies loaded with RequireJs. Without Squire, our tests run fine however as soon as we initialize a Squire object, everything start breaking: define(['squire'], function (Squire) { …
ajbeaven
  • 9,265
  • 13
  • 76
  • 121
3
votes
1 answer

Jasmine specs not being executed when injecting dependencies with Squire.js

I am attempting to run some Jasmine unit tests for a Backbone view, mocking out dependencies in Squire. The dependencies of my view are a Baseview, an ICanHaz template and an i18n translation. I mock out the dependencies after defining Squire and…
Simon Adcock
  • 3,554
  • 3
  • 25
  • 41
2
votes
1 answer

How to mock inline requirejs dependencies with squire for unit testing?

I'm using requirejs with inline requires, for instance: define(['someDep'], function(someDep) { return { someFn: function() { require(['anotherDep'], function(anotherDep) { anotherDep.anotherFn(); }); } } }); In my…
Paul Spencer
  • 1,355
  • 1
  • 8
  • 16
1
vote
1 answer

Global variable not being assigned in Jasmine unit test

I'm having some issues with a Jasmine unit-test seeing a global variable as undefined. I'm using Squire to mock some classes with the dependencies injected via RequireJS. Here is a trimmed down example of my unit test: My 'service' class…
dajaffe
  • 855
  • 13
  • 34
1
vote
1 answer

Using RequireJS with Mocha and SquireJS on node

I am trying to use RequireJS in node, and found difficulties with path issues. Here is a simple foo method that returns "foo" $ cat src/foo.js define([], function() { var foo = function() { return "foo"; }; return {…
itaifrenkel
  • 1,578
  • 1
  • 12
  • 26
1
vote
1 answer

How to run code before (or after) each test in karma

I'm looking to use squire.js with karma and want to do a squire.clean() to clean away all the mocks before the next test suite (I'm using jasmine) is run but I cannot see a way to configure karma to run something before (or after) a test suite. Is…
Jack Allan
  • 14,554
  • 11
  • 45
  • 57
0
votes
0 answers

Squirejs : requirejs is not defined

We have an amd/requirejs based web app. We came to a point to add a unit testing to our code. Googling returned that squireJs is best amd-require based mocking library. after installing, The problem is that we cant resolve the squirejs dependency.…
ISkandar
  • 17
  • 2
  • 9
0
votes
1 answer

Squire Mock Model not working with lists

In my Squire spec, I am mocking the model my controller takes. The controller dynamically adds a list of objects to the model, but it's not there when the spec runs the expectation. It works when a String parameter is dynamically added to the model.
ichan
  • 41
  • 3
0
votes
1 answer

How can I mock RequireJs loader plugin responses in unit tests

The code I'm trying to test relies on RequireJs loader plugins. Example with requirejs/text: require(['text!templates/foo'], function (data) { // handle loaded data }); For a specific unit test, I'm trying to mock the response for…
talkol
  • 12,564
  • 11
  • 54
  • 64