Skip to content

Commit

Permalink
test: fix npm install test failing in some cases (#569)
Browse files Browse the repository at this point in the history
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)
```
  • Loading branch information
abetomo authored Jul 30, 2021
1 parent 3b3da1c commit 07112be
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,20 +591,15 @@ describe('lib/main', function () {
})

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

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

beforeEach(() => {
return lambda._cleanDirectory(codeDirectory).then(() => {
fs.copySync(
path.join('node_modules', 'aws-sdk'),
path.join(codeDirectory, 'node_modules', 'aws-sdk')
)
return lambda._fileCopy(program, '.', codeDirectory, true)
})
beforeEach(async () => {
await lambda._cleanDirectory(codeDirectory)
await lambda._fileCopy(program, '.', codeDirectory, false)
})

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

0 comments on commit 07112be

Please sign in to comment.