Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
chore: add repositoryRoot test
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas committed Oct 12, 2021
1 parent f142338 commit bf8a1ea
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions tests/fixtures/node-monorepo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "local-node-module",
"version": "1.0.0",
"dependencies": {
"@netlify/mock-package": "1.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@netlify/mock-package')
21 changes: 21 additions & 0 deletions tests/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2165,3 +2165,24 @@ testMany('Correctly follows node_modules via symlink', ['bundler_esbuild', 'todo
const isEven = require(`${tmpDir}/function`)
t.is(isEven(2), '2 is even')
})

testMany(
'Can find Node modules in the `repositoryRoot` path, even if it is a parent directory of `basePath`',
['bundler_default', 'bundler_esbuild', 'bundler_nft'],
async (options, t) => {
const { path: tmpDir } = await getTmpDir({ prefix: 'zip-it-test' })
const fixtureDir = join(FIXTURES_DIR, 'node-monorepo')
const basePath = join(fixtureDir, 'packages', 'site-1', 'netlify', 'functions')
const opts = merge(options, {
basePath,
repositoryRoot: fixtureDir,
})
const result = await zipFunction(`${basePath}/function-1.js`, tmpDir, opts)

await unzipFiles([result])

const { mock } = require(`${tmpDir}/function-1.js`)

t.true(mock)
},
)

0 comments on commit bf8a1ea

Please sign in to comment.