Skip to content

Commit c674039

Browse files
committed
add test
1 parent 0a93cc8 commit c674039

File tree

14 files changed

+1326
-1
lines changed

14 files changed

+1326
-1
lines changed

packages/nextjs/jest.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
module.exports = require('../../jest/jest.config.js');
1+
const baseConfig = require('../../jest/jest.config.js');
2+
3+
module.exports = {
4+
...baseConfig,
5+
testPathIgnorePatterns: ['<rootDir>/test/buildProcess/'],
6+
};

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: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* eslint-disable no-console */
2+
import * as childProcess from 'child_process';
3+
import * as path from 'path';
4+
import { sync as rimrafSync } from 'rimraf';
5+
6+
const TEST_APP_DIR = 'test/buildProcess/testApp';
7+
8+
/**
9+
* Run the given shell command, piping the shell process's `stdin`, `stdout`, and `stderr` to that of the current
10+
* process if this script is run with the `--debug` flag. Returns contents of `stdout`.
11+
*/
12+
function run(cmd: string, options?: childProcess.ExecSyncOptions): string {
13+
return String(
14+
childProcess.execSync(cmd, {
15+
stdio: process.argv.includes('--debug') ? 'inherit' : 'ignore',
16+
...options,
17+
}),
18+
);
19+
}
20+
21+
// Note: We use a file dependency for the SDK, rather than linking it, because if it's linked, nextjs rolls the entire
22+
// SDK and all of its dependencies into a bundle, making it impossible to tell (from the NFT file, at least) what's
23+
// being included.
24+
console.log('Installing dependencies...');
25+
process.chdir(TEST_APP_DIR);
26+
rimrafSync('node_modules');
27+
run('yarn');
28+
29+
console.log('Building app...');
30+
rimrafSync('.next');
31+
run('yarn build');
32+
33+
console.log('App built. Running tests...');
34+
process.chdir('..');
35+
const jestConfigFile = path.resolve(process.cwd(), 'jest.config.js');
36+
try {
37+
// We have to specify the config file explicitly because otherwise it'll use the one at the root level of
38+
// `packages/nextjs`, since that's where the closest `package.json` file is
39+
run(`yarn jest --config ${jestConfigFile} tests`, { stdio: 'inherit' });
40+
} catch (err) {
41+
console.log('\nNot all build process tests passed.');
42+
}
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: 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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
}
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)