Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('Testing reportUnusedDisableDirectives', async ({ dir, capture, recorder }) => {
const idxFile = path.join(dir, 'src', 'index.js');
sfs.smartWrite(idxFile, ['// eslint-disable-next-line no-console\nmodule.exports = {};']);
sfs.smartWrite(path.join(dir, '.eslintrc.json'), { root: true });
const e = await capture(() => eslint(console, dir, { files: [idxFile] }));
expect(String(e)).to.equal('Error: Linter Problems');
const logs = recorder.get();
expect(logs.length).to.equal(1);
expect(logs[0]).to.include('Unused eslint-disable directive');
});
it('Testing Invalid File', async ({ dir, recorder }) => {
sfs.smartWrite(path.join(dir, 'index.js'), ['module.exports = "string"\n']);
try {
await eslint(console, dir, { files: [path.join(dir, 'index.js')] });
} catch (e) {
expect(String(e)).to.contain('Error: Linter Problems');
expect(String(recorder.get())).to.contain('4 problems (3 errors, 1 warning)');
}
});
});
it('Testing Ok', async ({ dir, recorder }) => {
sfs.smartWrite(path.join(dir, 'package.json'), {});
await depused(console, dir, []);
expect(recorder.get().length).to.equal(0);
});
it('Testing Failure', async ({ dir, capture, recorder }) => {
sfs.smartWrite(path.join(dir, 'test', 'index.spec.js'), ['']);
await capture(struct(console, dir, []));
const logs = recorder.get();
expect(logs.length).to.equal(1);
expect(logs[0]).to.contain('index.js to exist for ');
expect(logs[0]).to.contain('index.spec.js');
});
});
it('Testing Ok (YARN)', async ({ dir, recorder }) => {
sfs.smartWrite(path.join(dir, 'package.json'), { dependencies: { mocha: '5.0.5' }, license: 'MIT' });
exec.run('yarn install --silent --non-interactive', dir);
await depcheck(console, dir);
expect(recorder.get()).to.deep.equal([]);
});
});
it('Testing Update (Failure)', async ({ dir, capture, recorder }) => {
const result = ['Updated: CONFDOCS.md'];
sfs.smartWrite(path.join(dir, '.roboconfig.json'), {
'@blackflux/robo-config-plugin': {
tasks: [],
variables: {}
}
});
const e = await capture(() => robo(console, dir));
expect(e).to.deep.equal(result);
expect(recorder.get()).to.deep.equal(result);
});
it('Testing Ok', async ({ dir }) => {
sfs.smartWrite(path.join(dir, '.roboconfig.json'), {});
sfs.smartWrite(
path.join(dir, '.eslintrc.json'),
sfs.smartRead(path.join(__dirname, '..', '.eslintrc.json'))
);
fs.symlinkSync(
path.join(__dirname, '..', 'node_modules'),
path.join(dir, 'node_modules')
);
sfs.smartWrite(path.join(dir, 'package.json'), {
name: 'pkg',
dependencies: {
'@babel/register': '1.0.0'
},
main: 'index.js'
});
expect(await gardener({ cwd: dir })).to.equal(undefined);
it('Testing Ok', async ({ dir }) => {
sfs.smartWrite(path.join(dir, '.roboconfig.json'), {});
sfs.smartWrite(
path.join(dir, '.eslintrc.json'),
sfs.smartRead(path.join(__dirname, '..', '.eslintrc.json'))
);
fs.symlinkSync(
path.join(__dirname, '..', 'node_modules'),
path.join(dir, 'node_modules')
);
sfs.smartWrite(path.join(dir, 'package.json'), {
name: 'pkg',
dependencies: {
'@babel/register': '1.0.0'
},
main: 'index.js'
});
expect(await gardener({ cwd: dir })).to.equal(undefined);
});
it('Testing Ok', async ({ dir }) => {
sfs.smartWrite(path.join(dir, 'valid.yml'), ['double']);
await yamllint(console, dir, ['valid.yml']);
});
it('Testing Ok', async ({ dir }) => {
sfs.smartWrite(path.join(dir, '.roboconfig.json'), {});
sfs.smartWrite(
path.join(dir, '.eslintrc.json'),
sfs.smartRead(path.join(__dirname, '..', '.eslintrc.json'))
);
fs.symlinkSync(
path.join(__dirname, '..', 'node_modules'),
path.join(dir, 'node_modules')
);
sfs.smartWrite(path.join(dir, 'package.json'), {
name: 'pkg',
dependencies: {
'@babel/register': '1.0.0'
},
main: 'index.js'
});
expect(await gardener({ cwd: dir })).to.equal(undefined);
});