Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aura-require

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aura-require

Import Aura singletons and libraries as if they were CommonJS modules

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

aura-require

Facilitates unit testing of Aura singletons and libraries by allowing us to import them as if they were CommonJS modules. We can also pass a second argument that will be used to stub out any global variable references in the code being tested.

When testing without coverage, the code is parsed and executed in a JavaScript VM. When testing with coverage, we write the modified source to disk and then require() it. This is because most coverage tools hook into the require() in order to instrument the code before it executes.

example

const optionalGlobalStubs = {
  '$A': {
    get: () => {},
    set: () => {}
  },
  document: {
    querySelector: () => {}
  }
};

const libSetup = require('aura-require')(pathToLib, optionalGlobalStubs);

// <aura:include name="lib" imports="dependencyA, dependencyB"/>
const dependencyA = { foo: () => {} };
const dependencyB = { bar: () => {} };
const lib = libSetup(dependencyA, dependencyB);

install

npm install aura-require

usage

enable coverage

Declare the following environment variable to enable coverage: COVERAGE_ENABLED=true

build file directory

Declare the following environment variable to specify the directory in which the generated build files should go: BUILD_COVERAGE_DIR=build/coverage/

If not specified, the default directory is build/coverage/

example

{
  "script": {
    "test:coverage": "COVERAGE_ENABLED=true COVERAGE_BUILD_DIR=build/coverage/ tap --coverage src/test/unit/**/*.js"
  },
}

FAQs

Package last updated on 21 Jan 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc