- 
                Notifications
    You must be signed in to change notification settings 
- Fork 57
feat: bundler (esbuild, nextjs) integration tests #699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            gabrielmfern
  wants to merge
  83
  commits into
  canary
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
feat/integration-tests
  
      
      
   
  
    
  
  
  
 
  
      
    base: canary
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            83 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      ef6e3d2
              
                feat: get inbound emails v0 (#641)
              
              
                lucasfcosta 71e8a7d
              
                chore(deps): update dependency @biomejs/biome to v2.2.4 (#537)
              
              
                renovate[bot] 5a88b17
              
                feat: bump version for inbound release (#642)
              
              
                lucasfcosta 302e620
              
                chore: bump to 6.2.0-canary.1 (#649)
              
              
                gabrielmfern 1375e0b
              
                chore(deps): update dependency @types/node to v22.18.8 (#638)
              
              
                renovate[bot] f3f8df3
              
                chore(deps): update dependency typescript to v5.9.3 (#645)
              
              
                renovate[bot] be7f792
              
                chore(deps): update tj-actions/changed-files digest to d6f020b (#651)
              
              
                renovate[bot] 4658a96
              
                chore(deps): update pnpm to v10.18.0 (#653)
              
              
                renovate[bot] e5bbd56
              
                chore(deps): update dependency @biomejs/biome to v2.2.5 (#652)
              
              
                renovate[bot] f5abf15
              
                chore(deps): update dependency @types/react to v19.2.0 (#640)
              
              
                renovate[bot] 3f9190f
              
                feat: show headers in response (#657)
              
              
                lucasfcosta a7ba412
              
                chore: release new canary for headers (#658)
              
              
                lucasfcosta f1e7df4
              
                chore: improve PR title check error (#664)
              
              
                TyMick ed2e3c3
              
                feat: move emails inbound method to emails.receiving.<method> (#666)
              
              
                lucasfcosta 06dba00
              
                feat: move attachment inbound methods to be nested (#667)
              
              
                lucasfcosta 0dae1bc
              
                feat: add inbound listing method (#668)
              
              
                lucasfcosta ebc0e95
              
                feat: add pagination for inbound email attachments (#670)
              
              
                lucasfcosta 177020a
              
                chore(deps): update pnpm to v10.18.2 (#659)
              
              
                renovate[bot] 6f8a641
              
                chore(deps): update dependency @types/node to v22.18.9 (#669)
              
              
                renovate[bot] 499ec8e
              
                chore(deps): update pnpm/action-setup digest to 41ff726 (#665)
              
              
                renovate[bot] ffa8622
              
                feat: partial (API Keys, Audiences, and Contacts) non-mocked test cov…
              
              
                TyMick 446fb1e
              
                feat: bump version (#675)
              
              
                isabellaaquino feb8fd1
              
                feat: merge project preview branches (#680)
              
              
                Cisneiros f98e4c2
              
                feat: download from API's signed URLs instead of proxied routes (#676)
              
              
                lucasfcosta 1b1ac45
              
                fix: repo urls (#679)
              
              
                zenorocha a1ec05f
              
                feat: allow creating domain with capabilities through the api (#682)
              
              
                lucasfcosta 1b4ad28
              
                feat: add verify webhooks (#636)
              
              
                bukinoshita 8cde75f
              
                feat: avoid downloading attachments ourselves (#685)
              
              
                lucasfcosta 2a57b77
              
                chore: bump to canary 6.3.0-canary.1 (#687)
              
              
                lucasfcosta d6c46f2
              
                chore: limited variable types (#692)
              
              
                joaopcm 5e19da5
              
                fix: remove duplicated webhook import
              
              
                lucasfcosta d70ba6e
              
                fix: missing `statusCode` in ErrorRespnse type (#567)
              
              
                gabrielmfern a83f4db
              
                use try-catch again
              
              
                gabrielmfern 8cac8bd
              
                set the target to es2020 so the distributed uses async-await
              
              
                gabrielmfern 40c68e8
              
                use es2017
              
              
                gabrielmfern 2f650ee
              
                add first version of integration testing with nextjs/esbuild
              
              
                gabrielmfern 0d32c63
              
                use another package.json
              
              
                gabrielmfern 85b8635
              
                copy over the integrations to the user's tmp directory
              
              
                gabrielmfern 2352714
              
                remove unused depdnencies, update lock
              
              
                gabrielmfern ea82ac0
              
                ensure that the directory is deleted properly
              
              
                gabrielmfern 0b02b80
              
                lint
              
              
                gabrielmfern f8535e6
              
                fix linting warning
              
              
                gabrielmfern 84b76ff
              
                use js for config
              
              
                gabrielmfern e72ac57
              
                add types
              
              
                gabrielmfern e688309
              
                use js for nextjs integration
              
              
                gabrielmfern 6919b60
              
                use cjs for next.config
              
              
                gabrielmfern ef5f40a
              
                dont use sequential for the integration tests
              
              
                gabrielmfern ab1d509
              
                feat: get inbound emails v0 (#641)
              
              
                lucasfcosta ae5b029
              
                chore(deps): update dependency @biomejs/biome to v2.2.4 (#537)
              
              
                renovate[bot] a0b0943
              
                feat: bump version for inbound release (#642)
              
              
                lucasfcosta c0b1b4f
              
                chore: bump to 6.2.0-canary.1 (#649)
              
              
                gabrielmfern e648bb9
              
                chore(deps): update dependency @types/node to v22.18.8 (#638)
              
              
                renovate[bot] 34b2267
              
                chore(deps): update dependency typescript to v5.9.3 (#645)
              
              
                renovate[bot] 98fa90c
              
                chore(deps): update tj-actions/changed-files digest to d6f020b (#651)
              
              
                renovate[bot] 5d9d306
              
                chore(deps): update pnpm to v10.18.0 (#653)
              
              
                renovate[bot] a5df0a5
              
                chore(deps): update dependency @biomejs/biome to v2.2.5 (#652)
              
              
                renovate[bot] 9e4b04a
              
                chore(deps): update dependency @types/react to v19.2.0 (#640)
              
              
                renovate[bot] 294aeba
              
                feat: show headers in response (#657)
              
              
                lucasfcosta bfb4026
              
                chore: release new canary for headers (#658)
              
              
                lucasfcosta 2a5fd6d
              
                chore: improve PR title check error (#664)
              
              
                TyMick 2022031
              
                feat: move emails inbound method to emails.receiving.<method> (#666)
              
              
                lucasfcosta 54569ba
              
                feat: move attachment inbound methods to be nested (#667)
              
              
                lucasfcosta 236c533
              
                feat: add inbound listing method (#668)
              
              
                lucasfcosta 64a674f
              
                feat: add pagination for inbound email attachments (#670)
              
              
                lucasfcosta ffe4fce
              
                chore(deps): update pnpm to v10.18.2 (#659)
              
              
                renovate[bot] d4e34ee
              
                chore(deps): update dependency @types/node to v22.18.9 (#669)
              
              
                renovate[bot] 798d80b
              
                chore(deps): update pnpm/action-setup digest to 41ff726 (#665)
              
              
                renovate[bot] 41b7f7b
              
                feat: partial (API Keys, Audiences, and Contacts) non-mocked test cov…
              
              
                TyMick aae3602
              
                feat: bump version (#675)
              
              
                isabellaaquino 653a6a3
              
                feat: merge project preview branches (#680)
              
              
                Cisneiros 27a9a6c
              
                feat: download from API's signed URLs instead of proxied routes (#676)
              
              
                lucasfcosta 4ba8340
              
                fix: repo urls (#679)
              
              
                zenorocha afc815a
              
                feat: allow creating domain with capabilities through the api (#682)
              
              
                lucasfcosta 4747aea
              
                feat: add verify webhooks (#636)
              
              
                bukinoshita def00a1
              
                feat: avoid downloading attachments ourselves (#685)
              
              
                lucasfcosta de2e0e3
              
                chore: bump to canary 6.3.0-canary.1 (#687)
              
              
                lucasfcosta f6b5102
              
                chore: limited variable types (#692)
              
              
                joaopcm f0ccb0e
              
                fix: remove duplicated webhook import
              
              
                lucasfcosta 8d6cb55
              
                fix: missing `statusCode` in ErrorRespnse type (#567)
              
              
                gabrielmfern ac6889e
              
                feat: introduce the /segment API endpoints (#689)
              
              
                Cisneiros e00acf7
              
                Merge branch 'canary' into feat/integration-tests
              
              
                gabrielmfern b4e9697
              
                undo merge-introduced issues D:
              
              
                gabrielmfern 5858436
              
                remove extra import
              
              
                gabrielmfern File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
          Some comments aren't visible on the classic Files Changed page.
        
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| node_modules | ||
| dist | ||
| build | ||
| .env.test | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1 @@ | ||
| index.js | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { Resend } from 'resend'; | ||
|  | ||
| new Resend(''); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "dependencies": { | ||
| "esbuild": "0.25.11", | ||
| "resend": "../.." | ||
| }, | ||
| "scripts": { | ||
| "build": "esbuild ./index.ts --bundle --platform=node --target=node18 --outfile=./index.js" | ||
| } | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,93 @@ | ||||||
| import { spawnSync } from 'node:child_process'; | ||||||
| import fs from 'node:fs'; | ||||||
| import os from 'node:os'; | ||||||
| import path from 'node:path'; | ||||||
|  | ||||||
| describe('integrations', () => { | ||||||
| const sdkPath = path.resolve(__dirname, '..'); | ||||||
|  | ||||||
| beforeAll(() => { | ||||||
| const build = spawnSync('pnpm build', { | ||||||
| stdio: 'inherit', | ||||||
| cwd: path.resolve(__dirname, '..'), | ||||||
| shell: true, | ||||||
| }); | ||||||
| if (build.status !== 0) { | ||||||
| throw new Error('SDK build failed'); | ||||||
| } | ||||||
| }); | ||||||
|  | ||||||
| /** | ||||||
| * Create an extra temporary copy of the given integration so that there's @react-email/render module resolution from ../node_modules | ||||||
| * | ||||||
| * Also modifies the package.json to point to the SDK with an absolute path. | ||||||
| */ | ||||||
| async function prepareTemporaryIntegrationCopy(integrationPath: string) { | ||||||
| const temporaryIntegrationPath = path.resolve( | ||||||
| os.tmpdir(), | ||||||
| `resend-node-integration-${path.basename(integrationPath)}`, | ||||||
| ); | ||||||
| if (fs.existsSync(temporaryIntegrationPath)) { | ||||||
| await fs.promises.rm(temporaryIntegrationPath, { | ||||||
| recursive: true, | ||||||
| force: true, | ||||||
| }); | ||||||
| } | ||||||
| await fs.promises.mkdir(temporaryIntegrationPath, { recursive: true }); | ||||||
| await fs.promises.cp( | ||||||
| path.resolve(__dirname, integrationPath), | ||||||
| temporaryIntegrationPath, | ||||||
| { | ||||||
| recursive: true, | ||||||
| }, | ||||||
| ); | ||||||
|  | ||||||
| const testingLockPackageJson: { dependencies: Record<string, string> } = | ||||||
| JSON.parse( | ||||||
| await fs.promises.readFile( | ||||||
| path.resolve(temporaryIntegrationPath, 'package.json'), | ||||||
| 'utf8', | ||||||
| ), | ||||||
| ); | ||||||
| testingLockPackageJson.dependencies.resend = sdkPath; | ||||||
| await fs.promises.writeFile( | ||||||
| path.resolve(temporaryIntegrationPath, 'package.json'), | ||||||
| JSON.stringify(testingLockPackageJson, null, 2), | ||||||
| ); | ||||||
|  | ||||||
| return temporaryIntegrationPath; | ||||||
| } | ||||||
|  | ||||||
| test('nextjs', { timeout: 30_000 }, async () => { | ||||||
| const temporaryNextApp = await prepareTemporaryIntegrationCopy('./nextjs'); | ||||||
|  | ||||||
| const buildInstall = spawnSync( | ||||||
| 'npm install --install-links && npm run build', | ||||||
| { | ||||||
| stdio: 'inherit', | ||||||
| cwd: temporaryNextApp, | ||||||
| shell: true, | ||||||
| }, | ||||||
| ); | ||||||
| if (buildInstall.status !== 0) { | ||||||
| throw new Error('next.js build failed'); | ||||||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The esbuild integration test throws an error saying "next.js build failed", so an esbuild failure would surface with the wrong integration name, making it harder to triage. Prompt for AI agents
        Suggested change
       
 | ||||||
| } | ||||||
| }); | ||||||
|  | ||||||
| test('esbuild', { timeout: 30_000 }, async () => { | ||||||
| const temporaryIntegration = | ||||||
| await prepareTemporaryIntegrationCopy('./esbuild'); | ||||||
|  | ||||||
| const buildInstall = spawnSync( | ||||||
| 'npm install --install-links && npm run build', | ||||||
| { | ||||||
| stdio: 'inherit', | ||||||
| cwd: temporaryIntegration, | ||||||
| shell: true, | ||||||
| }, | ||||||
| ); | ||||||
| if (buildInstall.status !== 0) { | ||||||
| throw new Error('next.js build failed'); | ||||||
| } | ||||||
| }); | ||||||
| }); | ||||||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|  | ||
| # dependencies | ||
| package-lock.json | ||
| /node_modules | ||
| /.pnp | ||
| .pnp.* | ||
| .yarn/* | ||
| !.yarn/patches | ||
| !.yarn/plugins | ||
| !.yarn/releases | ||
| !.yarn/versions | ||
|  | ||
| # testing | ||
| /coverage | ||
|  | ||
| # next.js | ||
| /.next/ | ||
| /out/ | ||
|  | ||
| # production | ||
| /build | ||
|  | ||
| # misc | ||
| .DS_Store | ||
| *.pem | ||
|  | ||
| # debug | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| .pnpm-debug.log* | ||
|  | ||
| # env files (can opt-in for committing if needed) | ||
| .env* | ||
|  | ||
| # vercel | ||
| .vercel | ||
|  | ||
| # typescript | ||
| *.tsbuildinfo | ||
| next-env.d.ts | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { Resend } from 'resend'; | ||
|  | ||
| export function GET() { | ||
| new Resend(''); | ||
|  | ||
| return new Response('Hello from this API route!', { status: 200 }); | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1 @@ | ||
| module.exports = {}; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "dependencies": { | ||
| "next": "15.5.6", | ||
| "react": "19.2.0", | ||
| "react-dom": "19.2.0", | ||
| "resend": "../.." | ||
| }, | ||
| "scripts": { | ||
| "build": "next build" | ||
| } | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Check failure
Code scanning / CodeQL
Insecure temporary file High test
Copilot Autofix
AI 9 days ago
To securely create a temporary directory, use a well-established library like
tmp, which ensures random directory names, exclusive creation, and appropriate permissions.Steps:
tmpin the test file.path.resolve(os.tmpdir(), ...), calltmp.dirSync()(or its async equivalent), which returns a unique, safely created temp directory path.tmphandle creation and permissions.Required changes:
import tmp from 'tmp';near the top.prepareTemporaryIntegrationCopy, replace the explicit construction oftemporaryIntegrationPath, its manual deletion, and the explicitmkdirwith a singletmp.dirSync()call.temporaryIntegrationPathas needed.