Files
cypress/packages/server/test/unit/fs_spec.js
T
Tim Griesser e4442ab7ac refactor: remove global.root & usage in require (#19336)
* refactor: remove global.root & use in requires

* fix types
2021-12-11 14:06:49 -05:00

33 lines
752 B
JavaScript

require('../spec_helper')
const { fs } = require(`../../lib/util/fs`)
describe('lib/util/fs', () => {
beforeEach(() => {
return sinon.spy(console, 'error')
})
it('warns when trying to use fs.existsSync', () => {
fs.existsSync(__filename)
const warning = 'WARNING: fs sync methods can fail due to EMFILE errors'
expect(console.error).to.be.calledWith(warning)
})
context('fs.pathExists', () => {
it('finds this file', () => {
return fs.pathExists(__filename)
.then((found) => {
expect(found).to.be.true
})
})
it('does not find non-existent file', () => {
return fs.pathExists('does-not-exist')
.then((found) => {
expect(found).to.be.false
})
})
})
})