GithubHelp home page GithubHelp logo

derickwarshaw / webpack-ava-recipe Goto Github PK

View Code? Open in Web Editor NEW

This project forked from greyepoxy/webpack-ava-recipe

0.0 2.0 0.0 3 KB

An example project demonstrating how to setup webpack to compile test files before passing them to ava to be run.

JavaScript 100.00%

webpack-ava-recipe's Introduction

webpack-ava-recipe

An example project demonstrating how to setup webpack to compile test files before passing them to ava to be run.

Why run webpack on your tests?

Ava is a great test runner but if you require your code to go through some form of pre-compile step it will either not work at all or require further configuration. For example say you are using react and .jsx files. Ava has a decent solution where you would add the module 'babel-register' as a startup require. This works great but as your project expands you might run into the situation were your test runtimes start to increase more rapidly than you would expect. This occurs because when Ava runs the tests it loads 'babel-register' on each test process which will compile your code on each test run. Usually the cost of compiling can be mitigated through file watch caching, on save only the module/file edited will need to be re-compiled. Unfortunately, while ava --watch does a good job of caching the test sources, since it relies on 'babel-register' for the compiling step it does not do any compiling caching. This is where webpack comes in, run independently it has caching support and will cut down your codes re-compile times whenever you want to run your tests.

Another advantage is that webpack will support any file extension that you need while currently Ava does not.

Disadvantages

Ava by itself can find all Ava tests in your source files and run them. With the approach detailed in this project you have to have a 'tests.js' file that imports all of your test files so that they will be compiled together.

Usage

npm test - Compile and run your tests

npm run watch:test - Compiles your tests whenever the source changes and runs them as well

I am on windows so my watch command here is probably not ideal for other platforms, webpack --watch & ava --watch & might work on linux but I am not sure.

webpack-ava-recipe's People

Contributors

greyepoxy avatar

Watchers

 avatar  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.