Package detail

@serverless/test

serverless28.6kMIT11.1.1

Test utilities for serverless libraries

test, mocha

readme

@serverless/test

Internal test utils that aid Serverless organization libraries

Provides a reliable test suite setup, based on Mocha test framework

Installation

npm i --save-dev mocha@9 chai chai-as-promised @serverless/test

Mocha Setup

Preconfigure Mocha to rely on a custom reporter, included with this package, which applies workarounds for known Mocha issues, and exposes endpoint through which other utils may observe Mocha runner flow.

In package.json add mocha section with reporter option set, and recommended extensions as follows:

{
  "mocha": {
    "require": [
      "@serverless/test/setup/patch",
      "@serverless/test/setup/log",
      "@serverless/test/setup/mock-homedir",
      "@serverless/test/setup/mock-cwd",
      "@serverless/test/setup/restore-env"
    ]
  }
}

Setup extensions

All setup extensions are documented in docs/setup folder

Utils

All utils are documented in docs folder

Binaries

All binaries are documented in docs/bin folder

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

11.1.1 (2023-05-29)

Bug Fixes

11.1.0 (2022-10-20)

Features

11.0.2 (2022-10-11)

Bug Fixes

11.0.1 (2022-07-07)

Bug Fixes

11.0.0 (2022-05-26)

⚠ BREAKING CHANGES

  • preventCicrularDepPropertyWarning util was removed as no longer needed.

Features

Maintenance Improvements

10.0.4 (2022-04-29)

Bug Fixes

Maintenance Improvements

10.0.3 (2022-04-07)

Bug Fixes

Maintenance Improvements

10.0.2 (2022-02-24)

Bug Fixes

10.0.1 (2022-02-11)

Bug Fixes

10.0.0 (2022-02-03)

⚠ BREAKING CHANGES

  • awsRequest no longer requires and retrieves AWS SDK on it's own. The SDK client constructor needs to be passed to directly
  • Support for mocha v8 was removed. Use mocha v9 instead

Features

Maintenance Improvements

9.0.0 (2022-01-27)

⚠ BREAKING CHANGES

  • serverless v2 is no longer supported
  • Node.js version 12 or later is required (dropped support for v10)

Features

Maintenance Improvements

8.8.0 (2022-01-03)

Features

8.7.0 (2021-12-28)

Features

8.6.0 (2021-12-20)

Features

Maintenance Improvements

8.5.0 (2021-11-09)

Features

8.4.0 (2021-09-20)

Features

8.3.2 (2021-09-16)

Maintainance improvements

8.3.1 (2021-07-21)

Bug Fixes

  • Run Serverless: Ensure CLI input resolution patch is applied when modules cache is cleared (#105) (b32eb2e) (Mariusz Nowak)

8.3.0 (2021-07-07)

Features

Maintenance Improvements

8.2.0 (2021-06-21)

Features

8.1.1 (2021-06-08)

Bug Fixes

8.1.0 (2021-04-16)

Features

  • Run Serverless: Pass serviceDir and configurationFilename to Serverless constructor (#97) (2a7c95e) (Mariusz Nowak)

8.0.2 (2021-04-15)

Bug Fixes

8.0.1 (2021-04-15)

Maintenance Improvements

8.0.0 (2021-04-09)

⚠ BREAKING CHANGES

  • Run Serverless: cliArgs options was dropped in favor more programmatic command and options. runServerless can only be used with serverless which provides lib/configuration/variables/index.js util.

Features

7.11.0 (2021-03-26)

Features

7.10.1 (2021-03-09)

Bug Fixes

Maintenance Improvements

7.10.0 (2021-03-02)

Features

7.9.0 (2021-02-24)

Features

7.8.0 (2021-02-11)

Features

Bug Fixes

7.7.0 (2021-02-08)

Features

7.6.0 (2021-02-05)

Features

7.5.0 (2021-02-02)

Features

7.4.0 (2021-01-22)

Features

7.3.0 (2021-01-18)

Features

7.2.0 (2021-01-13)

Features

7.1.0 (2021-01-08)

Features

7.0.0 (2021-01-04)

⚠ BREAKING CHANGES

  • Node.js version 10 or later is required (dropped support for v6 and v8)
  • Mocha version 8 is required (switched from v6)
  • Removed custom Mocha reporter setup/mocha-reporter in favor of simple patch extension (setup/patch)
  • Removed Mocha dedicated async leaks detector
  • get-fixture-engine.js util was renamed to setup-fixture-engine.js

Features

6.2.3 (2020-11-24)

Bug Fixes

6.2.2 (2020-11-04)

Bug Fixes

6.2.1 (2020-11-04)

Bug Fixes

6.2.0 (2020-11-04)

Features

6.1.2 (2020-10-23)

Bug Fixes

6.1.1 (2020-10-23)

Bug Fixes

6.1.0 (2020-10-22)

Features

6.0.0 (2020-10-19)

⚠ BREAKING CHANGES

  • Mocha: Rename restore-cwd extension to mock-cwd extension. It was changed to also mock current working directory to homedir (which if mock-homedir is used, points temp directory)

Features

5.2.0 (2020-10-09)

Features

5.1.0 (2020-09-08)

Features

5.0.0 (2020-09-08)

⚠ BREAKING CHANGES

  • Fixtures Engine: fixtures.map, fixtures.extend were removed and fixtures.setup was redesigned to address all fixture setup cases. Now each fixture is copied to temporary folder, which is retured by fixtures.setup

Features

4.9.2 (2020-09-04)

Bug Fixes

4.9.1 (2020-09-04)

Bug Fixes

4.9.0 (2020-09-04)

Features

Bug Fixes

4.8.0 (2020-09-01)

Features

4.7.0 (2020-08-31)

Features

4.6.0 (2020-08-19)

Features

4.5.0 (2020-08-18)

Features

Bug Fixes

4.4.0 (2020-08-07)

Features

4.3.2 (2020-07-22)

Bug Fixes

4.3.1 (2020-07-16)

Bug Fixes

4.3.0 (2020-07-15)

Features

4.2.0 (2020-07-08)

Features

4.1.0 (2020-07-08)

Features

  • Run Serverless: Provide access to generated CloudFormation template on result object (7b25ceb) (Mariusz Nowak)

4.0.0 (2020-07-08)

⚠ BREAKING CHANGES

  • Run Serverless: runServerless no longer resolves with serverless instance directly. Now data object is returned with serverless and stdoutData properties

Features

  • Run Serverless: Mute stdout and expose its content at stdoutData (028c99c)

3.9.0 (2020-07-01)

Features

3.8.1 (2020-06-23)

Bug Fixes

3.8.0 (2020-06-03)

Features

  • Handle internal rename in serverless of lib/utils/isTrackingDisabled.js into lib/utils/anallytics/areDisabled.js (90d71a1) (Mariusz Nowak)

3.7.0 (2020-05-14)

Features

Bug Fixes

3.6.0 (2020-04-15)

Features

3.5.5 (2020-04-05)

3.5.4 (2020-03-20)

Bug Fixes

  • Mocha Isolated: Do not output progress list on lone test run (1051a88)

3.5.3 (2020-02-20)

Bug Fixes

  • Async Leaks Detector: Bump timeout to avoid false positives (9d51af2)

3.5.2 (2020-02-12)

3.5.1 (2020-01-22)

Bug Fixes

  • Do not crash during Mocha event propagation (e2ff7c6)
  • Mocha Fixes: Ensure to expose uncaught exceptions after fails (281616b)

3.5.0 (2020-01-20)

Features

  • Mocha Isolated: In multi process run live output last test run (3abf05e)

3.4.0 (2020-01-13)

Features

  • awsRequest util (85f9a84)
  • Recognize dashboard test setup env vars (69659bf)

3.3.1 (2020-01-10)

Bug Fixes

  • Mocha Fixes: Fix mocha process 'exit' listener detection (7d494af)
  • Do not hard crash on async leaks detection (d834e22)

3.3.0 (2019-12-20)

Features

  • Log: Ensure timestamps by logs (bc268d0)

3.2.2 (2019-12-13)

Bug Fixes

  • Increase async leaks detector timeout (a882845)
  • Mocha Isolated: To avoid confusion do not crash non 1 error codes (6759893)

3.2.1 (2019-12-13)

Bug Fixes

  • Mocha Isolated: Ensure to validate options not path arguments (770d171)

3.2.0 (2019-12-13)

Features

  • Mocha Isolated: Allow to customize number of workers (cd9892a)

3.1.0 (2019-12-12)

Features

  • restore-env mocha setup extension (9894fb1)

3.0.0 (2019-11-19)

Features

  • Run Serverless::
    • Pass Serverless constructor and cwd to before hook (d0e0530)
    • Replace whitelist approach with blacklist one (b1faeb9)

BREAKING CHANGES

  • Run Serverless: pluginPathsWhitelist and lifecycleHookNamesWhitelist options were removed in favor of pluginPathsBlacklist and lifecycleHookNamesBlacklist

2.5.0 (2019-11-08)

Bug Fixes

  • Increase async leaks detector wait gap (5cc991c)

Features

  • Mocha Isolated::
    • --bail' option to abort after first fail (d0c7a3a)
    • Do not hard exit process on test fail (3b86bea)
    • Output stdout and stderr of finalized test in sync (77de37a)
  • Run Serverless:
    • Whitelist SERVERLESS_BINARY_PATH env var (a767b67)

2.4.0 (2019-10-23)

Features

  • Log:
    • Improve Mocha test boundary logs (2f34d89)
    • Prevent writing cumulated logs if there's only mocha logs (3cf086b)

2.3.0 (2019-10-22)

Features

  • Log: Mark suite and test start in logs (c5dd212)

2.2.0 (2019-10-21)

Bug Fixes

  • Run Serverless:
    • Do not assign 'undefined' value to env var (a928602)

Features

  • Run Serverless:
    • envWhitelist option (ad6e047)
    • Validate eventually passed 'env' option (6cee5ae)
  • resolveAwsEnv util (2eb4630)
  • resolveEnv util (c5856e7)
  • Log writing setup option (4e02245)

2.1.0 (2019-10-15)

Features

  • provision-tmp-dir util (6954597)
  • Inquirer Stub:
    • Auto reset eventual previous stub (ae048ec)
    • Stub createPromptModule (8331c08)
    • Support prompt collections (edf29aa)
  • Run Serverless:
    • Support config option, as an alternative to cwd (6362b23)
    • Confirm whitelisted lifecycle hooks were executed (76c66b6)
    • Ensure whitelisted lifecycle hooks are recognized (3f1f7f3)
    • Ensure whitelisted plugins exist (fd7a222)
    • Support relative plugin paths (95766e9)
    • Validate input arguments (2ec470d)
    • Validate input serverlessPath (2e9419f)
    • Validate paths of whitelisted plugins upfront (cc85e5b)

2.0.0 (2019-09-19)

Bug Fixes

  • Cleanup homedir only after top suite run finalizes (523f48d)
  • Support validation for 'password' type in inquirer stub (bcbcf4c)

Features

  • Support hooks in run-serverless util (c385862)

refactor

  • Rename hookNamesWhitelist run-serverless option (9df7313)

BREAKING CHANGES

  • In run-serveless util hookNamesWhitelist option was renamed to lifecycleHookNamesWhitelist. It's to not confuse it with hooks option (which is not about lifecycle hooks)

1.0.0 (2019-09-13)

Initial implementation, derived from serveress codebase.

Patched Mocha runner with extensions

Binaries

Utilties

  • Run serverless util (32f5429)
  • Configure inquirer stub util (664982e)
  • Disable serverless stats requests util (834b627)