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

@moltin/component-test-framework

Package Overview
Dependencies
Maintainers
9
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@moltin/component-test-framework

A framework for component tests written using ts-flow

  • 0.0.1
  • npm
  • Socket score

Version published
Weekly downloads
158
increased by9.72%
Maintainers
9
Weekly downloads
 
Created
Source

Elasticpath Component Test Framework

Installation

The framework comes with a set of Yeoman generators which can help scaffold the entire component test directory.

For this to work, you will need Yeoman installed (npm i -g yo).

From within the root directory of the service:

$ yo component-tests:scaffold

If the component-tests directory already exists, you will be prompted to resolve the conflicts.

Using the Framework

The framework exposes a few classes:

Api

This is the class responsible for communicating with your API. You can use the methods directly, however, it's usually a better idea to have it as a binding.

Example

import { binding, then } from 'cucumber-tsflow'
import { Api } from 'component-test-framework'

@binding([ Api ])
export default class MyStepDefinitions {
    constructor(protected api: Api) {
    
    }
    
    @then(...)
    public async myStep(): void {
      await this.api.get('/products')
    }
    
    ...

Examples are generated once you run the scaffold generator.

ResourceStore

When working with the api in your component tests, it's often benificial to reference the last created resource

Example

Given An admin creates a product
When They get the created product

For this, we can use the ResourceStore. When ever you use the Api module, it stores the resource that was created, or fetched in the resource store. Knowing that, we can create our step definition to easily fetch the last created resource

Example

import { ResourceStore } from 'component-test-framework'
...
const resource =  ResourceStore.LastCreated('file')

We can also get all of the resources under one type

Example

import { ResourceStore } from 'component-test-framework'
...
const resource =  ResourceStore.FetchByType('file')

And find a resource

Example

import { ResourceStore } from 'component-test-framework'
...
const resource =  ResourceStore.Find('file', 'id', 'abc-123')

FAQs

Package last updated on 24 May 2021

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