Skip to content

Commit 617fcbc

Browse files
committed
Use node version to pick a parser and skip unsupported tests
1 parent fea4a36 commit 617fcbc

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

__tests__/helper.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import getProp from '../src/getProp';
22

3-
const parser = require('@babel/parser');
3+
const nodeVersion = parseInt(process.version.match(/^v(\d+)\./)[1], 10);
4+
5+
export const fallbackToBabylon = nodeVersion < 6;
6+
7+
const parser = fallbackToBabylon ? require('babylon') : require('@babel/parser');
48

59
const defaultPlugins = ['jsx', 'functionBind', 'estree', 'objectRestSpread', 'optionalChaining'];
610
let plugins = [...defaultPlugins];

__tests__/src/getPropValue-test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
/* eslint-env mocha */
22
/* eslint no-template-curly-in-string: 0 */
33
import assert from 'assert';
4-
import { extractProp, changePlugins } from '../helper';
4+
import { extractProp, changePlugins, fallbackToBabylon } from '../helper';
55
import getPropValue from '../../src/getPropValue';
66

7+
const describeIfNotBabylon = fallbackToBabylon ? describe.skip : describe;
8+
79
describe('getPropValue', () => {
810
it('should export a function', () => {
911
const expected = 'function';
@@ -876,7 +878,7 @@ describe('getPropValue', () => {
876878
});
877879
});
878880

879-
describe('Typescript', () => {
881+
describeIfNotBabylon('Typescript', () => {
880882
beforeEach(() => {
881883
changePlugins(pls => [...pls, 'typescript']);
882884
});

0 commit comments

Comments
 (0)