NPM module - izara-testing: Difference between revisions
(Created page with "= Overview = Code shared by multiple repositories used for testing, can by npm installed using --save-dev setting, only used in local environments. The module has the follow...") |
|||
(10 intermediate revisions by the same user not shown) | |||
Line 13: | Line 13: | ||
Build unit tests from [[Service - Integration Test Config|Integration Test Config]] service which must be cloned into the same root directory as the service being tested because config files are linked to using relative paths. | Build unit tests from [[Service - Integration Test Config|Integration Test Config]] service which must be cloned into the same root directory as the service being tested because config files are linked to using relative paths. | ||
== Function - | == Function - getResourceConfig == | ||
<syntaxhighlight lang="JavaScript"> | <syntaxhighlight lang="JavaScript"> | ||
/** | /** | ||
* Get the configuration for one resource | * Get the configuration for one resource | ||
* @param {string} serviceName - Service name for the resource | |||
* @param {string} resourceType - Resource type | |||
* @param {string} resourceName - Name of the resource | * @param {string} resourceName - Name of the resource | ||
* | * | ||
* @returns {object} | * @returns {object} One resource configuration | ||
*/ | */ | ||
module.exports. | module.exports.getResourceConfig = (serviceName, resourceType, resourceName) => { | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Function - | == Function - getUnitTestConfig == | ||
<syntaxhighlight lang="JavaScript"> | <syntaxhighlight lang="JavaScript"> | ||
/** | /** | ||
* Extract all matching unit test configurations | * Extract all matching unit test configurations | ||
* @param {string} resourceName - Name of the resource | * @param {string} serviceName - Service name for the resource | ||
* @param { | * @param {string} resourceType - Resource type | ||
* @param {string} resourceName - Name of the resource | |||
* @param {Object[]} integrationTestTags - can be used to only extract unit tests from the specified integrationTestTags | |||
* | * | ||
* @returns { | * @returns {Object[]} array of unit test configuration objects that match the given params | ||
*/ | */ | ||
module.exports. | module.exports.getUnitTestConfig = (serviceName, resourceType, resourceName, integrationTestTags = NULL) => { | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:NPM modules|izara-testing]] | == Function - getEventConfig == | ||
<syntaxhighlight lang="JavaScript"> | |||
/** | |||
* Get the configuration for one event | |||
* @param {string} eventTag - Tag of the event required | |||
* | |||
* @returns {object} One event configuration | |||
*/ | |||
module.exports.getEventConfig = (eventTag) => { | |||
</syntaxhighlight> | |||
== Function - integrationTest..(?need function name) == | |||
<syntaxhighlight lang="JavaScript"> | |||
/** | |||
* Get the configuration for one event | |||
* @param {string} ... - ... | |||
* | |||
* @returns {object} ... | |||
*/ | |||
module.exports.xxxxx = (eventTag) => { | |||
</syntaxhighlight> | |||
Creates and runs unit tests generated from Integration Test Config service. | |||
Uses a test configuration's invokes property to generate AWSMock for all Lambda functions invoked by the function being tested. Currently when matching a Lambda invoke to an inputEvent is unable to match properties that are objects (or at least an empty object), nor match specific nested properties, job for the future. | |||
[[Category:NPM modules| izara-testing]] |
Latest revision as of 12:34, 28 November 2020
Overview
Code shared by multiple repositories used for testing, can by npm installed using --save-dev setting, only used in local environments.
The module has the following components:
TestLog
Functions that handle log output from test scripts, including a LOG_LEVEL setting that can be affect which log results are outputted and thisLine which assists outputting debug information such as line number where the log was called from.
IntegrationTestConfig
Build unit tests from Integration Test Config service which must be cloned into the same root directory as the service being tested because config files are linked to using relative paths.
Function - getResourceConfig
/**
* Get the configuration for one resource
* @param {string} serviceName - Service name for the resource
* @param {string} resourceType - Resource type
* @param {string} resourceName - Name of the resource
*
* @returns {object} One resource configuration
*/
module.exports.getResourceConfig = (serviceName, resourceType, resourceName) => {
Function - getUnitTestConfig
/**
* Extract all matching unit test configurations
* @param {string} serviceName - Service name for the resource
* @param {string} resourceType - Resource type
* @param {string} resourceName - Name of the resource
* @param {Object[]} integrationTestTags - can be used to only extract unit tests from the specified integrationTestTags
*
* @returns {Object[]} array of unit test configuration objects that match the given params
*/
module.exports.getUnitTestConfig = (serviceName, resourceType, resourceName, integrationTestTags = NULL) => {
Function - getEventConfig
/**
* Get the configuration for one event
* @param {string} eventTag - Tag of the event required
*
* @returns {object} One event configuration
*/
module.exports.getEventConfig = (eventTag) => {
Function - integrationTest..(?need function name)
/**
* Get the configuration for one event
* @param {string} ... - ...
*
* @returns {object} ...
*/
module.exports.xxxxx = (eventTag) => {
Creates and runs unit tests generated from Integration Test Config service.
Uses a test configuration's invokes property to generate AWSMock for all Lambda functions invoked by the function being tested. Currently when matching a Lambda invoke to an inputEvent is unable to match properties that are objects (or at least an empty object), nor match specific nested properties, job for the future.