Skip to content
This repository has been archived by the owner on Nov 28, 2017. It is now read-only.

avajs/babel-plugin-ava-test-data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babel-plugin-ava-test-data Build Status

My bee's knees module

Install

$ npm install --save babel-plugin-ava-test-data

Usage

import * as babel from 'babel-core';
import plugin from 'babel-plugin-test-data';

const result = babel.transform(
	`
	import test from 'ava';

	test(t => {});                   // adds empty array to metadata
	test.skip('foo', t => {});       // adds array ['skip'] to metadata
	test.serial.cb('foo', t => {});  // adds array ['serial', 'cb'] to metadata
	`,
	{plugins: [plugin]}
);

//

const metadata = plugin.metadata(result);

Resulting metadata is:

metadata = [
	[],
	['skip'],
	['serial', 'cb']
]

API

plugin.metadata(result, [create])

Extract the test call metadata from the babel result.

result

Type: Babel transform result

The result from calling babel.transform.

create

Type: boolean
Default: false

If true and no test calls were found, create and return an empty array. This guarantees the result is always an array. Otherwise it will return null if no test calls are found.

License

MIT © James Talmage