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

@travetto/test

Package Overview
Dependencies
Maintainers
1
Versions
353
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@travetto/test

Declarative test framework that provides hooks for high levels of integration with the travetto framework and test plugin

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
544
increased by270.07%
Maintainers
1
Weekly downloads
 
Created
Source

travetto: Test

This module provides unit testing functionality that integrates with the framework. It is a declarative framework, using decorators to define tests and suites. The test produces results in the TAP 13 format.

The test-plugin directly integrates with the module to provide real-time feedback on unit tests.

Definition

A test suite is a collection of individual tests. All test suites are classes with the @Suite decorator. Tests are defined as methods on the suite class, using the @Test decorator. All tests intrinsically support async/await.

Additionally, the the suite classes support Dependency Injection.

A simple example would be:

import * as assert from 'assert';

@Suite()
class SimpleTest {

  private complexService: ComplexService;

  @Test()
  async test1() {
    let val = await this.complexService.doLongOp();
    assert(val === 5);
  }

  @Test()
  test2() {
    assert(/abc/.test(text));
  }
}

Assertions

A common aspect of the tests themselves are the assertions that are made. Node provides a built-in assert library. The framework uses AST transformations to modify the assertions to provide integration with the test module, and to provide a much higher level of detail in the failed assertions.

For example:

assert({size: 20, address: { state: 'VA' }} === {});

would generate the error:

AssertionError(
  message="{size: 20, address: {state: 'VA' }} should deeply strictly equal {}"
)

Execution

travetto-test is packaged as a included script to execute tests from the command line. The script can be invoked as

./node_modules/.bin/travetto-test test/.*

All tests should be under the test/.* folders. The pattern for tests is defined as a regex and not standard globbing.

Keywords

FAQs

Package last updated on 15 Jul 2018

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