New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

jsdom-angularjs

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsdom-angularjs

> Enables angular in Node.js

latest
npmnpm
Version
0.0.8
Version published
Maintainers
1
Created
Source

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

FAQs

Package last updated on 30 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts