aura-require
Import Aura singletons and libraries as if they were CommonJS modules
Last updated 4 years ago by ekashida .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install aura-require 
SYNC missed versions from official npm registry.

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"
  },
}

Current Tags

  • 1.0.0                                ...           latest (4 years ago)

1 Versions

  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |