karma-cson-fixtures-preprocessor
v0.0.1
Published
A Karma plugin to compile CSON files and make them accessible from Javascript code
Downloads
4
Maintainers
Readme
karma-cson-fixtures-preprocessor
Preprocessor for converting .cson files into .js files and making them accessible from karma test environment
Installation
{
"devDependencies": {
"karma": "~0.12.1",
"karma-cson-fixtures-preprocessor": "0.0.x"
}
}
Configuration
// karma.conf.js
module.exports = (config) ->
config.set({
preprocessors:
"./fixtures/**/*.cson": ["cson_fixtures"]
files: [
"./fixtures/**/*.cson"
]
csonFixturesPreprocessor:
// strip this from the file path \ fixture name
stripPrefix: "test/fixtures",
// strip this to the file path \ fixture name
prependPrefix: "mock/",
// change the global fixtures variable name
variableName: "__mocks__"
How it works
Preprocessor requires .cson files and converts them into .js files by storing json data as javascript objects under __fixtures__
namespace.
the following file:
./fixtures/test.cson
{
a: "test"
}
will be accessible in your test environment:
var fixture = window.__fixtures__["fixtures/test"];
fixture["a"] // => 'test'