Skip to content
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
68 lines (47 sloc) 2.17 KB

JSPM and SystemJS for ES2015

Translations: Français

It requires a special loader helper to correctly resolve imports of JSPM packages when using AVA. The purpose of the loader is to allow you to run your tests without having to pre-build your JSPM project.


This recipe has only been tested with JSPM v0.17.0-beta.22, but it should work with any version of JSPM v0.17 and may work with v0.16.


Set up your Babel options to work with AVA if you have not already. NOTE: You can keep additional configuration in your JSPM config files to override these settings during bundling and building.

$ npm install --save-dev @babel/preset-env
	"presets": ["@babel/preset-env"]

You can find more information about setting up Babel with AVA in the Babel recipe.

JSPM Loader Helper

You will need to install the AVA JSPM loader as a dev dependency. You will also need to install @babel/register.

$ npm install --save-dev ava-jspm-loader @babel/register

You will also need to update your AVA config in the package.json or ava.config.js to use the JSPM loader.


	"ava": {
		"require": [

NOTE: If you use async/await in your source code (not in your test code), you will need to install @babel/polyfill and add it to your require array.

Example test file

Note that you will need to use System.import paths for all of your project files. So, if you named your project app and you want to import your main.js into a test file, you will need to import main from 'app/main'.

import test from 'ava';
import main from 'app/main';  // Maps to your JSPM config for "app/main.js"
import BigNumber from 'bignumber.js';  // In jspm_packages

function fn() {
	return Promise.resolve(new BigNumber('1234567890.123456789'));

test('example test', async t => { fn()).toString(), '1234567890.123456789');
You can’t perform that action at this time.