@magic/test

Getting Started

Be in a nodejs project.

Install

npm i --save-dev --save-exact @magic/test

Create a Test File

Create a test file in the test/ directory. The filename is used in test output, and the path should mirror your source structure:

// test/yourFileToTest.jsexport default [  { fn: () => true, expect: true, info: 'true is true' },  { fn: () => 1 + 1, expect: 2, info: 'basic math' },]

Note: the test function is called automatically. expect: true is optional.

Add npm Scripts

Add test scripts to your package.json:

{  "scripts": {    "test": "t -p",    "coverage": "t"  }}

t -p runs tests in production mode (no coverage, faster). t runs with coverage.

Run Tests

npm test

Example Output

### Testing package: @magic/testRan 2 tests. Passed 2/2 100%

Faster output from a bigger project:

### Testing package: @artificialmuseum/engineRan 90307 tests in 274.5ms. Passed 90307/90307 100%

Next Steps