This is a simple example of how to use grunt-castle to unit test a client-server AMD code base.
In case you are wondering what the names in this example are referencing, "The Sneetches".
In this example the fictitious application resides in the lib directory. The lib/modules
directory represents code that was imported from another project. This imported code
is used to highlight a case for mocking dependencies.
The test/mocks directory contains the testing mocks. Grunt-castle supports two types
of mocks, AMD and global. money.js is a global mock, which is referenced in the
application code. test/mocks/modules/sylvesterMcMonkeyMcBean.js mocks the application
file lib/modules/sylvesterMcMonkeyMcBean.js.
The test/specs directory contains the specifications to be tested. In this example there
is only 1 specification, test/specs/shared/sneetch.js. This specification will be tested on
both the client and the server.
The grunt-castle task configuration for this example can be found in Gruntfile.js.
For further information about grunt-castle visit the Github repo.
First clone the repo:
git clone [email protected]:jstrimpel/grunt-castle-example.gitSecond install the dependencies from the local repo directory:
npm installThird run the tests:
grunt castleYou are done.