Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should skip updating stash if there are errors during linting', async () => {
expect.assertions(4)
hasPartiallyStagedFiles.mockImplementationOnce(() => Promise.resolve(true))
getStagedFiles.mockImplementationOnce(async () => ['sample.js'])
execa.mockImplementation(() =>
Promise.resolve({
stdout: '',
stderr: 'Linter finished with error',
code: 1,
failed: true,
cmd: 'mock cmd'
})
)
try {
await runAll({ config: { '*.js': ['echo "sample"'] } })
} catch (err) {
console.log(err)
}
expect(console.printHistory()).toMatchSnapshot()
expect(gitStashSave).toHaveBeenCalledTimes(1)
const execa = require('execa')
const mockedEnv = require('mocked-env')
const now = require('../now')
const {NOW_BIN} = now
jest.mock('execa')
execa.mockImplementation(() => Promise.resolve({stderr: '', stdout: ''}))
describe('now()', () => {
let restoreEnv = () => {}
afterEach(() => restoreEnv())
it('throws if process.env.NOW_TOKEN is falsy', () => {
mockEnv({NOW_TOKEN: ''})
expect(() => now()).toThrow()
})
it('calls `npx now --token=$NOW_TOKEN` with no additional args', () => {
mockEnv({NOW_TOKEN: 'xyz'})
now()
expect(execa).lastCalledWith(NOW_BIN, ['--token=xyz'], {stderr: 'inherit'})
})
beforeEach(() => {
execa.mockImplementation(() => Promise.resolve({stdout: '', stderr: ''}))
actionStatus.mockImplementation(() => Promise.resolve())
})