/cta-common

Primary LanguageJavaScriptOtherNOASSERTION

cta-common

Build Status Coverage Status codecov

Common Modules for Compass Test Automation, One of Libraries in CTA-OSS Framework

General Overview

Overview

In cta-common, there are four modules as following:

  1. ConfigModule
  2. LoaderModule
  3. RootModule
  4. ValidateModule

These modules providing common functions across CTA-OSS.

Guidelines

We aim to give you brief guidelines here.

const cta_common = require("cta-common");

1. ConfigModule

It loads the config for specified module using file structure: [module_root]/lib/apps/main/config.

const moduleName = "sample-module";
const config = cta_common.config(moduleName);

The file, which locates at sample-module/lib/apps/main/config/index.js, is loaded as the config.

2. LoaderModule

It loads modules from all *.js files in specified directory. Other extension files are excluded.

For example: there are three files in directory: module1.js, module2.js, and module3.js

Output as Array

const sampleDirectory = "sample-directory";
const array_output = cta_common.loader.asArray(sampleDirectory);
// array_output = [ {default_export_module1}, {default_export_module2}, {default_export_module3} ]

Output as Object

const sampleDirectory = "sample-directory";
const object_output = cta_common.loader.asObject(sampleDirectory);
// object_output = {
//   module1: {default_export_module1},
//   module2: {default_export_module2},
//   module3: {default_export_module3},
// }

3. RootModule

It resolves the root directory of module.

const moduleName = "samplemodule";
const root = cta_common.root(moduleName);

For example, [executing_application]/node_modules/samplemodule

4. ValidateModule

It validates the input against specified pattern.

const input = { value: "sample input" };
const pattern = "object";

const output = cta_common.validate(input, pattern);

This module is used to validate a bridge and a tool in CTA-OSS.

To Do

Plan for next release