Skip to content

Commit 07112be

Browse files
authored
test: fix npm install test failing in some cases (#569)
If you copy only part of node_modules, `npm install` may behave the same as `npm ci`. This sometimes causes tests that check for identical timestamps to fail. ```js assert.equal(beforeAwsSdkStat.ctimeMs, afterAwsSdkStat.ctimeMs) ```
1 parent 3b3da1c commit 07112be

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

test/main.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -591,20 +591,15 @@ describe('lib/main', function () {
591591
})
592592

593593
describe('_npmInstall', function () {
594-
_timeout({ this: this, sec: 30 }) // ci should be faster than install
594+
_timeout({ this: this, sec: 60 }) // ci should be faster than install
595595

596596
// npm treats files as packages when installing, and so removes them.
597597
// Test with `devDependencies` packages that are not installed with the `--production` option.
598598
const nodeModulesMocha = path.join(codeDirectory, 'node_modules', 'mocha')
599599

600-
beforeEach(() => {
601-
return lambda._cleanDirectory(codeDirectory).then(() => {
602-
fs.copySync(
603-
path.join('node_modules', 'aws-sdk'),
604-
path.join(codeDirectory, 'node_modules', 'aws-sdk')
605-
)
606-
return lambda._fileCopy(program, '.', codeDirectory, true)
607-
})
600+
beforeEach(async () => {
601+
await lambda._cleanDirectory(codeDirectory)
602+
await lambda._fileCopy(program, '.', codeDirectory, false)
608603
})
609604

610605
describe('when package-lock.json does exist', () => {

0 commit comments

Comments
 (0)