Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update babylon plugins in BabylonParser, solves #3070 #3076

Merged
merged 2 commits into from
Mar 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions fixtures/global_its.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ it('works with flow functions', () => {
function foo(x: string): string { return x; }
});

it('works with JSX', ()=> {
const foo = () => <div></div>;
})

it.only('works with it.only', () => {

});
Expand Down
21 changes: 13 additions & 8 deletions fixtures/parserTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function parserTests(parse: (file: string) => any) {
it('For the simplest it cases', () => {
const data = parse(`${fixtures}/global_its.example`);

expect(data.itBlocks.length).toEqual(7);
expect(data.itBlocks.length).toEqual(8);

const firstIt = data.itBlocks[0];
expect(firstIt.name).toEqual('works with old functions');
Expand All @@ -41,25 +41,30 @@ function parserTests(parse: (file: string) => any) {
expect(thirdIt.start).toEqual({column: 1, line: 10});
expect(thirdIt.end).toEqual({column: 3, line: 12});

const fourthIt = data.itBlocks[3];
expect(fourthIt.name).toEqual('works with it.only');
expect(fourthIt.start).toEqual({column: 1, line: 14});
expect(fourthIt.end).toEqual({column: 3, line: 16});
const fourthIt = data.itBlocks[2];
expect(fourthIt.name).toEqual('works with flow functions');
expect(fourthIt.start).toEqual({column: 1, line: 10});
expect(fourthIt.end).toEqual({column: 3, line: 12});

const fifthIt = data.itBlocks[4];
expect(fifthIt.name).toEqual('works with fit');
expect(fifthIt.name).toEqual('works with it.only');
expect(fifthIt.start).toEqual({column: 1, line: 18});
expect(fifthIt.end).toEqual({column: 3, line: 20});

const sixthIt = data.itBlocks[5];
expect(sixthIt.name).toEqual('works with test');
expect(sixthIt.name).toEqual('works with fit');
expect(sixthIt.start).toEqual({column: 1, line: 22});
expect(sixthIt.end).toEqual({column: 3, line: 24});

const seventhIt = data.itBlocks[6];
expect(seventhIt.name).toEqual('works with test.only');
expect(seventhIt.name).toEqual('works with test');
expect(seventhIt.start).toEqual({column: 1, line: 26});
expect(seventhIt.end).toEqual({column: 3, line: 28});

const eigthIt = data.itBlocks[7];
expect(eigthIt.name).toEqual('works with test.only');
expect(eigthIt.start).toEqual({column: 1, line: 30});
expect(eigthIt.end).toEqual({column: 3, line: 32});
});

it('For its inside describes', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-editor-support/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"license": "BSD-3-Clause",
"main": "build/index.js",
"dependencies": {
"babylon": "^6.13.0"
"babylon": "^6.14.1"
},
"typings": "index.d.ts"
}
4 changes: 2 additions & 2 deletions packages/jest-editor-support/src/parsers/BabylonParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ const parse = (file: string) => {
const babel = JSON.parse(babelRC);

const plugins = Array.isArray(babel.plugins)
? babel.plugins.concat(['flow'])
: ['flow'];
? babel.plugins.concat(['*'])
: ['*'];

const config = {plugins, sourceType: 'module'};
const ast = babylon.parse(data, config);
Expand Down