Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dvoytenko committed Dec 13, 2023
1 parent 549ab01 commit 7e38116
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/production/transpile-packages/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function Root({ children }: { children: React.ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}
15 changes: 15 additions & 0 deletions test/production/transpile-packages/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { GetObjectCommand } from '@aws-sdk/client-s3'
import { isObject } from 'lodash'

export default function Page() {
const command = new GetObjectCommand({
Bucket: 'bucket',
Key: 'key1',
})
return (
<div>
<div id="key">Key: {command.input.Key}</div>
<div id="isObject">isObject: {String(isObject(command))}</div>
</div>
)
}
8 changes: 8 additions & 0 deletions test/production/transpile-packages/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
transpilePackages: ['@aws-sdk/client-s3'],
}

module.exports = nextConfig
29 changes: 29 additions & 0 deletions test/production/transpile-packages/transpile-packages.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { createNextDescribe } from 'e2e-utils'

createNextDescribe(
'app fetch build cache',
{
files: __dirname,
dependencies: {
'@aws-sdk/client-s3': 'latest',
lodash: 'latest',
},
},
({ next }) => {
it('should render page with dependencies', async () => {
const $ = await next.render$('/')
expect($('#key').text()).toBe('Key: key1')
expect($('#isObject').text()).toBe('isObject: true')
})

it('should treat lodash as an external package', async () => {
const output = await next.readFile('.next/server/app/page.js')
expect(output).toContain('require("lodash')
})

it('should bundle @aws-sdk/client-s3 as a transpiled package', async () => {
const output = await next.readFile('.next/server/app/page.js')
expect(output).not.toContain('require("@aws-sdk/client-s3")')
})
}
)

0 comments on commit 7e38116

Please sign in to comment.