Skip to content

Commit e932b14

Browse files
committed
add test
1 parent 80d2fcc commit e932b14

File tree

14 files changed

+3190
-0
lines changed

14 files changed

+3190
-0
lines changed

packages/nextjs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"lint:prettier": "prettier --check \"{src,test,scripts}/**/*.ts\"",
6767
"test": "run-s test:unit",
6868
"test:all": "run-s test:unit test:integration",
69+
"test:build": "yarn ts-node test/buildProcess/runTest.ts",
6970
"test:unit": "jest",
7071
"test:integration": "test/run-integration-tests.sh && yarn test:types",
7172
"test:types": "cd test/types && yarn test",
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* eslint-disable no-console */
2+
import * as childProcess from 'child_process';
3+
import { sync as rimrafSync } from 'rimraf';
4+
5+
const TEST_APP_DIR = 'test/buildProcess/testApp';
6+
7+
/**
8+
* Run the given shell command, piping the shell process's `stdin`, `stdout`, and `stderr` to that of the current
9+
* process if this script is run with the `--debug` flag. Returns contents of `stdout`.
10+
*/
11+
function run(cmd: string, options?: childProcess.ExecSyncOptions): string {
12+
return String(
13+
childProcess.execSync(cmd, {
14+
stdio: process.argv.includes('--debug') ? 'inherit' : 'ignore',
15+
...options,
16+
}),
17+
);
18+
}
19+
20+
// Note: We use a file dependency for the SDK, rather than linking it, because if it's linked, nextjs rolls the entire
21+
// SDK and all of its dependencies into a bundle, making it impossible to tell (from the NFT file, at least) what's
22+
// being included.
23+
console.log('Installing dependencies...');
24+
process.chdir(TEST_APP_DIR);
25+
rimrafSync('node_modules');
26+
run('yarn');
27+
28+
console.log('Building app...');
29+
rimrafSync('.next');
30+
run('yarn build');
31+
32+
console.log('App built. Running tests...');
33+
process.chdir('..');
34+
try {
35+
// Even if this script hasn't been run with the `--debug` flag, we want the output of tests to be shown.
36+
run('yarn jest tests', { stdio: 'inherit' });
37+
} catch (err) {
38+
console.log('\nNot all build process tests passed.');
39+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
.pnpm-debug.log*
27+
28+
# local env files
29+
.env*.local
30+
31+
# vercel
32+
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo
36+
next-env.d.ts
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
```
12+
13+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
14+
15+
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.
16+
17+
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.
18+
19+
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
20+
21+
## Learn More
22+
23+
To learn more about Next.js, take a look at the following resources:
24+
25+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
26+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
27+
28+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
29+
30+
## Deploy on Vercel
31+
32+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
33+
34+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// const nextConfig = {
2+
// }
3+
//
4+
// module.exports = nextConfig
5+
6+
const { withSentryConfig } = require('@sentry/nextjs');
7+
8+
const moduleExports = {
9+
reactStrictMode: true,
10+
swcMinify: true,
11+
eslint: {
12+
ignoreDuringBuilds: true,
13+
},
14+
sentry: {
15+
// Suppress the warning message from `handleSourcemapHidingOptionWarning` in `src/config/webpack.ts`
16+
// TODO (v8): This can come out in v8, because this option will get a default value
17+
hideSourceMaps: false,
18+
},
19+
};
20+
const SentryWebpackPluginOptions = {
21+
dryRun: true,
22+
silent: true,
23+
};
24+
25+
module.exports = withSentryConfig(moduleExports, SentryWebpackPluginOptions);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "testapp",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev",
7+
"build": "next build",
8+
"start": "next start",
9+
"lint": "next lint"
10+
},
11+
"dependencies": {
12+
"@sentry/nextjs": "file:../../../",
13+
"@vercel/nft": "latest",
14+
"next": "13.0.1",
15+
"react": "18.2.0",
16+
"react-dom": "18.2.0"
17+
},
18+
"devDependencies": {
19+
"jest": "^29.3.1"
20+
}
21+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import * as Sentry from '@sentry/nextjs';
2+
3+
Sentry.init({
4+
dsn: 'https://[email protected]/1337',
5+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import * as Sentry from '@sentry/nextjs';
2+
3+
Sentry.init({
4+
dsn: 'https://[email protected]/1337',
5+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"dogs": "are great"
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function MyApp({ Component, pageProps }) {
2+
return <Component {...pageProps} />;
3+
}
4+
5+
export default MyApp;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import * as fs from 'fs';
2+
import * as path from 'path';
3+
4+
export default function handler(req, res) {
5+
const dogData = JSON.parse(fs.readFileSync(path.resolve('../../dogs.json')));
6+
dogData.test = 'something';
7+
res.status(200).json(dogData);
8+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Home() {
2+
return <div>This is the homepage.</div>;
3+
}

0 commit comments

Comments
 (0)