GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - apibyexample/karma-abe-json2js-preprocessor: A Karma Plugin - Convert JSON files into JS

BranchesTags
Open more actions menu

Latest commit

 

History

19 Commits
19 Commits

Folders and files

NameName
Last commit message
Last commit date
lib
lib
 
 
test/e2e
test/e2e
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.jscsrc
.jscsrc
 
 
.jshintrc
.jshintrc
 
 
.npmignore
.npmignore
 
 
.travis.yml
.travis.yml
 
 
Gruntfile.js
Gruntfile.js
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
package.json
package.json
 
 

Repository files navigation

Build Status devDependency Status peerDependency Status Monthly downloads License

karma-abe-json2js-preprocessor

A Karma Plugin - Convert JSON files into JS

Installation

Install the plugin from npm:

npm install karma-abe-json2js-preprocessor --save-dev

Example configuration:

// karma.conf.js
module.exports = function(karma) {
  karma.set({
    files: [
      '*.js',
      '*.json'
    ],
    frameworks: ['abeJson']
    preprocessors: {
      '*.json': ['json2js']
    }
  });
};

Add the json2js preprocessor and abeJson as a framework within your Karma configuration file.

Usage

So you want to incorporate the following json file into your tests:

  • tests/json/example.json
{
    "description": "Sample for ABE implementations",
    "url": "/",
    "method": "POST",
    "examples": {
        "OK": {
            "description": "Sample successful POST",
            "request": {
                "queryParams": { "verbose": "0" },
                "headers": { "Content-type": "application/json" },
                "body": { "payload": "Sample" }
            },
            "response": {
                "status": 201,
                "headers": { "Content-type": "application/json" },
                "body": { "id": 1, "payload": "Sample" }
            }
        }
    }
}

You can use new AbeJson('json/example.json') to load that specific file:

describe('Test JSON', function () {

    var json;

    beforeEach(function () {
        abeJson = new AbeJson('json/example.json');
    });

    it('has the correct description', function () {
        expect(abeJson.get().description)
            .toEqual('Sample for ABE implementations');
    });
});

Note: that we use the parent directory and file name.

API

  • abeJson.get

    Returns the json

  • abeJson.example(exampleName)

    Returns a specific example

    In the case above, abeJson.example('OK')

  • abeJson.load(file)

    Loads in a new json file

About

A Karma Plugin - Convert JSON files into JS

Resources

Readme
MIT license
Activity
Custom properties

Stars

1 star

Watchers

5 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.