Git Product home page Git Product logo

jsdom-angularjs's Introduction

jsdom-angularjs

Enables angular in Node.js

jsdom-angularjs will inject angular into your Node.js environment. Useful for running, in Node.js, tests that are made for browsers.

Install

Requires jsdom.

npm install --save-dev --save-exact jsdom jsdom-angularjs

Note

jsdom-angularjs now requires jsdom v10 or above.

Usage

Just invoke it to turn your Node.js environment into a DOM environment.

require('jsdom-angularjs')()

// you can now use the DOM
let controller = angular.module('module').controller('controller')

To clean up after itself, just invoke the function it returns.

var cleanup = require('jsdom-angularjs')()

// do things

cleanup()

Tape

In tape, run it before your other tests.

require('jsdom-angularjs')()

test('your tests', (t) => {
  /* and so on... */
})

Mocha

Simple: Use Mocha's --require option. Add this to the test/mocha.opts file (create it if it doesn't exist)

-r jsdom-angularjs/register

Advanced: For finer control, you can instead add it via mocha's before and after hooks.

before(function () {
  this.jsdomAngularJS = require('jsdom-angularjs')()
})

after(function () {
  this.jsdomAngularJS()
})

ES2015

If you prefer to use import rather than require, you might want to use jsdom-global/register instead. Place it on top of your other import calls.

import 'jsdom-angularjs/register'
// ...

Thanks

jsdom-angularjs © 2019+, Igo Ventura. Released under the [MIT] License.

GitHub @igoventura  ·  Twitter @igoventura

jsdom-angularjs's People

Contributors

igoventura avatar dependabot[bot] avatar

Stargazers

Mr. Andrey avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.