Skip to content

Commit 5732742

Browse files
committed
eslint-module-utils: In tests move require stub parser to the top.
1 parent d397b9b commit 5732742

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tests/src/core/parse.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { getFilename } from '../utils'
77

88
describe('parse(content, { settings, ecmaFeatures })', function () {
99
const path = getFilename('jsx.js')
10+
const parseStubParser = require('./parseStubParser')
11+
const parseStubParserPath = require.resolve('./parseStubParser')
1012
let content
1113

1214
before((done) =>
@@ -25,8 +27,8 @@ describe('parse(content, { settings, ecmaFeatures })', function () {
2527
it('passes expected parserOptions to custom parser', function () {
2628
const parseSpy = sinon.spy()
2729
const parserOptions = { ecmaFeatures: { jsx: true } }
28-
require('./parseStubParser').parse = parseSpy
29-
parse(path, content, { settings: {}, parserPath: require.resolve('./parseStubParser'), parserOptions: parserOptions })
30+
parseStubParser.parse = parseSpy
31+
parse(path, content, { settings: {}, parserPath: parseStubParserPath, parserOptions: parserOptions })
3032
expect(parseSpy.callCount, 'custom parser to be called once').to.equal(1)
3133
expect(parseSpy.args[0][0], 'custom parser to get content as its first argument').to.equal(content)
3234
expect(parseSpy.args[0][1], 'custom parser to get an object as its second argument').to.be.an('object')
@@ -50,8 +52,8 @@ describe('parse(content, { settings, ecmaFeatures })', function () {
5052
it('should take the alternate parser specified in settings', function () {
5153
const parseSpy = sinon.spy()
5254
const parserOptions = { ecmaFeatures: { jsx: true } }
53-
require('./parseStubParser').parse = parseSpy
54-
expect(parse.bind(null, path, content, { settings: { 'import/parsers': { [require.resolve('./parseStubParser')]: [ '.js' ] } }, parserPath: null, parserOptions: parserOptions })).not.to.throw(Error)
55+
parseStubParser.parse = parseSpy
56+
expect(parse.bind(null, path, content, { settings: { 'import/parsers': { [parseStubParserPath]: [ '.js' ] } }, parserPath: null, parserOptions: parserOptions })).not.to.throw(Error)
5557
expect(parseSpy.callCount, 'custom parser to be called once').to.equal(1)
5658
})
5759

0 commit comments

Comments
 (0)