Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrtenz committed Nov 14, 2022
1 parent e3829a7 commit cecf1b8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/typescript/src/__test__/dummy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// This file is only used to test the config.
console.log('Hello, world!');
12 changes: 11 additions & 1 deletion packages/typescript/src/index.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { ESLint } = require('eslint');
const { resolve } = require('path');

const config = require('.');

Expand All @@ -7,9 +8,18 @@ describe('index', () => {
const api = new ESLint({
baseConfig: config,
useEslintrc: false,
overrideConfig: {
parserOptions: {
tsconfigRootDir: resolve(__dirname, '..'),
project: 'tsconfig.json',
},
},
});

const result = await api.lintText(`console.log('Hello, world!');\n`);
// In order to test rules that require type information, we need to actually
// compile the file with TypeScript, so rather than using `api.lintText()`,
// we use `api.lintFiles()` and pass in a file that we know will pass.
const result = await api.lintFiles(resolve(__dirname, '__test__/dummy.ts'));

expect(result[0].messages).toStrictEqual([]);
expect(result[0].warningCount).toBe(0);
Expand Down
3 changes: 3 additions & 0 deletions packages/typescript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"include": ["src"]
}

0 comments on commit cecf1b8

Please sign in to comment.