karma-cson-fixtures-preprocessor

0.0.1 • Public • Published

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'

Package Sidebar

Install

npm i karma-cson-fixtures-preprocessor

Weekly Downloads

1

Version

0.0.1

License

ISC

Last publish

Collaborators

  • kmdavis