Coder Social home page Coder Social logo

daveek / jest-schematic Goto Github PK

View Code? Open in Web Editor NEW

This project forked from briebug/jest-schematic

0.0 1.0 0.0 4.32 MB

Angular schematic for adding Jest and the required files to an Angular CLI project

License: MIT License

JavaScript 4.75% TypeScript 47.73% HTML 47.37% SCSS 0.15%

jest-schematic's Introduction

Jest Angular Schematic

This schematic will configure Angular to execute unit tests with Jest for single projects or workspaces.

npm (scoped)

Usage ๐Ÿš€

ng add @briebug/jest-schematic
  • install Jest, types and a builder
  • add Jest configuration files
  • remove Karma & Jasmine along with their configuration files

Optionally: install globally

npm install -g @briebug/jest-schematic

Then in an Angular CLI project run

ng g @briebug/jest-schematic:add

jest-schematic-demo-500

Issues ๐Ÿง

If you're experiencing issues when trying to run your tests with Jest, please view the documentation for the builder which uses jest-preset-angular.

A common issues involves library dependencies. For example if your app depends on NgRx you'll need to tell Jest to compile the sources explicitly by appending it to the transformIgnorePatterns property in the jest.config.js file.

module.exports = {
  transformIgnorePatterns: ['node_modules/(?!(jest-test|@ngrx))'],
};

Issues with this schematic can be filed here.

Learning Resources ๐Ÿ“š

Development ๐Ÿ› 

Getting started

Clone or fork the repo and install the dependencies with Yarn

yarn

Test schematic changes against a sandbox app

When running locally, schematic changes will be applied to a test app in the /sandboxes directory. /sandboxes contain a single app repo and a workspace repo with an application and library.

Run the following when a schematic change is made to test:

// runs against /sandboxes/single-app
yarn test single

// runs against /sandboxes/workspace
yarn test workspace

โš  Be careful not to check in changes to the sandbox directory unless necessary. โš 

Reset sandboxes to their version controlled state

This will reset the sandboxes to their HEAD commit and remove un-tracked files.

yarn reset

Test schematics against a local project

  • run yarn build to compile the schematic in watch mode
  • open another shell, cd into the local repo you want to run the schematic against, and run yarn link @briebug/jest-schematic. This assumes you've run yarn link in this repo on your machine.
    • this will symlink the projects so that the Jest schematic command runs from you're local filesystem
  • in the local repo you want to run the schematic against, run ng g @briebug/jest-schematic:add

Dev tips

For faster developing, find and comment out the following line to avoid npm installing dependencies

context.addTask(new NodePackageInstallTask());

jest-schematic's People

Contributors

anthonymjones avatar dependabot[bot] avatar luettenberg avatar schuchard avatar zoltan-nz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.