-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
autofix.test.js
43 lines (35 loc) · 1 KB
/
autofix.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { join } from 'path';
import { copySync, removeSync, readFileSync } from 'fs-extra';
import pack from './utils/pack';
describe('autofix stop', () => {
const entry = join(__dirname, 'fixtures/fixable-clone.js');
beforeAll(() => {
copySync(join(__dirname, 'fixtures/fixable.js'), entry);
});
afterAll(() => {
removeSync(entry);
});
test.each([[{}], [{ threads: false }]])(
'should not throw error if file ok after auto-fixing',
async (cfg) => {
const compiler = pack('fixable-clone', {
...cfg,
fix: true,
extensions: ['js', 'cjs', 'mjs'],
overrideConfig: {
rules: { semi: ['error', 'always'] },
},
});
const stats = await compiler.runAsync();
expect(stats.hasWarnings()).toBe(false);
expect(stats.hasErrors()).toBe(false);
expect(readFileSync(entry).toString('utf8')).toMatchInlineSnapshot(`
"function foo() {
return true;
}
foo();
"
`);
},
);
});