Skip to content

Commit 32cc779

Browse files
iancwfkling
authored andcommittedMar 7, 2018
Allow specifying a testName for inline tests (#218)
* Allow specifying a testName for inline tests This is a small change that makes test output a bit nicer when writing multiple inline tests. * Update readme
1 parent 2f062e1 commit 32cc779

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ This will run two tests: One for `__testfixtures__/FirstFixture.input.js` and on
360360
#### `defineInlineTest`
361361
```js
362362
const transform = require('../myTransform');
363-
defineInlineTest(transform, {}, 'input', 'expected output');
363+
defineInlineTest(transform, {}, 'input', 'expected output', 'test name (optional)');
364364
```
365365

366366
### Example Codemods

‎sample/__tests__/reverse-identifiers-test.js

+5
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,9 @@ var droWtsrif = 'Hello ';
3333
var droWdnoces = 'world';
3434
var egassem = droWtsrif + droWdnoces;
3535
`);
36+
defineInlineTest(transform, {},
37+
'function aFunction() {};',
38+
'function noitcnuFa() {};',
39+
'Reverses function names'
40+
);
3641
});

‎src/testUtils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ function defineTest(dirName, transformName, options, testFilePrefix) {
9393
}
9494
exports.defineTest = defineTest;
9595

96-
function defineInlineTest(module, options, input, expectedOutput) {
97-
it('transforms correctly', () => {
96+
function defineInlineTest(module, options, input, expectedOutput, testName) {
97+
it(testName || 'transforms correctly', () => {
9898
runInlineTest(module, options, {
9999
source: input
100100
}, expectedOutput);

0 commit comments

Comments
 (0)
Please sign in to comment.