karma-cson-fixtures-preprocessor
A Karma plugin to compile CSON files and make them accessible from Javascript code
Last updated 6 years ago by kmdavis .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install karma-cson-fixtures-preprocessor 
SYNC missed versions from official npm registry.

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'

Current Tags

  • 0.0.1                                ...           latest (6 years ago)

1 Versions

  • 0.0.1                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (2)
Dev Dependencies (0)
None
Dependents (2)

Copyright 2014 - 2016 © taobao.org |