New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@alfheim/generator-nef-tests

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alfheim/generator-nef-tests

Yeoman generator for basic NEF component testing suite

  • 0.3.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

@alfheim/generator-nef-tests

Travis npm (scoped with tag) GitHub license PRs welcome

This package is part of the battery used to create new components for the Nasdaq Experience Framework. This package creates an <ComponentName>.styles.ts[x] file, which contains styles for the created component.

Note: It is recommended that you install and use generator-nef-component rather than installing this package directly, unless you need to modify the individual file generators.

By default, a testing file for the component named Test created using this generator looks as follows:

import { mount, render, shallow } from "enzyme";
import React from "react";
import faker from "faker";

import StyledTest from "./Test.styles";

import Test from ".";

describe("Test", () => {
  let props;
  let mountedTest;
  let renderedTest;
  let shallowTest;

  const mountTestComponent = () => {
    if (!mountedTest) {
      mountedTest = mount(<Test {...props} />);
    }
    return mountedTest;
  };

  const renderTestComponent = () => {
    if (!renderedTest) {
      renderedTest = render(<Test {...props} />);
    }
    return renderedTest;
  };

  const shallowTestComponent = () => {
    if (!shallowTest) {
      shallowTest = shallow(<Test {...props} />);
    }
    return shallowTest;
  };

  beforeEach(() => {
    props = {
      children: faker.lorem.paragraph(),
      className: faker.random.word(),
      id: faker.random.word(),
      name: faker.random.word(),
      style: { color: faker.internet.color() }
    };
    mountedTest = undefined;
    renderedTest = undefined;
    shallowTest = undefined;
  });

  // Shallow / unit tests begin here
  it(`should always render a 'StyledTest' component`, () => {
    expect(shallowTestComponent().find(StyledTest).length).toBe(1);
  });

  it(`should always pass all its props to the 'StyledTest'`, () => {
    expect(
      shallowTestComponent()
        .find(StyledTest)
        .props()
    ).toMatchObject(props);
  });

  // Render / mount / integration tests begin here
});

Options

Additionally, the following options can be provided when calling the generator:

  • --no-mount-tests: disable mount tests when generating the test file
  • --no-render-tests: disable render tests when generating the test file
  • --no-shallow-tests: disable shallow tests when generating the test file

Getting started

To install, simply run:

yarn add @alfheim/generator-nef-tests --dev

or

npm install @alfheim/generator-nef-tests --dev 

Contributing

We'd love to have your helping hand on alfheim! Go over to our issues section and see if there's anything we're looking for help with OR open up a PR if you have an idea for a way to improve the library.

License

Alfheim is open source software licensed as MIT.

Keywords

FAQs

Package last updated on 25 Feb 2020

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