Skip to content

Commit

Permalink
Add with-app-dir integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre de la Martiniere committed Nov 1, 2022
1 parent 61c1745 commit b224849
Show file tree
Hide file tree
Showing 18 changed files with 565 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ jobs:
- name: Install tests apps dependencies (swc)
run: yarn --frozen-lockfile --cwd src/__tests__/__apps__/swc

- name: Install tests apps dependencies (with-app-dir)
run: yarn --frozen-lockfile --cwd src/__tests__/__apps__/with-app-dir

- name: Build test apps
run: npm run test:prepare

Expand Down
6 changes: 6 additions & 0 deletions jest-puppeteer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const yarnWorkspacesAppPath = 'src/__tests__/__apps__/yarn-workspaces/app';
const yarnWorkspacesSymlinksAppPath = 'src/__tests__/__apps__/yarn-workspaces-symlinks/app';
const pnpmAppPath = 'src/__tests__/__apps__/pnpm';
const swcAppPath = 'src/__tests__/__apps__/swc/app';
const withAppDirAppPath = 'src/__tests__/__apps__/with-app-dir/app';

module.exports = {
launch: {
Expand Down Expand Up @@ -36,5 +37,10 @@ module.exports = {
launchTimeout: 20000,
port: 3506,
},
{
command: `yarn --cwd ${withAppDirAppPath} run start --port 3507`,
launchTimeout: 20000,
port: 3507,
},
],
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"test:prepare:yarn-workspaces-symlinks": "yarn --cwd src/__tests__/__apps__/yarn-workspaces-symlinks/app run build",
"test:prepare:pnpm": "npm run build --prefix=src/__tests__/__apps__/pnpm",
"test:prepare:swc": "yarn --cwd src/__tests__/__apps__/swc/app run build",
"test:prepare": "npm run test:prepare:npm-basic && npm run test:prepare:yarn-workspaces && npm run test:prepare:yarn-workspaces-symlinks && npm run test:prepare:pnpm && npm run test:prepare:swc"
"test:prepare:with-app-dir": "yarn --cwd src/__tests__/__apps__/with-app-dir/app run build",
"test:prepare": "npm run test:prepare:npm-basic && npm run test:prepare:yarn-workspaces && npm run test:prepare:yarn-workspaces-symlinks && npm run test:prepare:pnpm && npm run test:prepare:swc && npm run test:prepare:with-app-dir"
},
"repository": {
"type": "git",
Expand Down
3 changes: 3 additions & 0 deletions scripts/next-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ yarn --cwd "$ROOT/src/__tests__/__apps__/yarn-workspaces-symlinks/app" add "next

echo "==================== SWC ===================="
yarn --cwd "$ROOT/src/__tests__/__apps__/swc/app" add "next@$NEXT_VERSION"

echo "==================== WITH-APP-DIR ===================="
yarn --cwd "$ROOT/src/__tests__/__apps__/with-app-dir/app" add "next@$NEXT_VERSION"
9 changes: 9 additions & 0 deletions src/__tests__/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ __apps__/yarn-workspaces-symlinks/shared-ui
__apps__/swc/shared
__apps__/swc/shared-ts
__apps__/swc/shared-ui
__apps__/with-app-dir/shared
__apps__/with-app-dir/shared-ts
__apps__/with-app-dir/shared-ui
__apps__/shared
__apps__/shared-ts
__apps__/shared-ui
Expand Down Expand Up @@ -40,3 +43,9 @@ __apps__/swc/app/components
__apps__/swc/app/pages
!__apps__/swc/app/pages/.keep
__apps__/swc/app/next-transpile-modules.js

__apps__/with-app-dir/app/components
!__apps__/with-app-dir/app/components/.keep
__apps__/with-app-dir/app/pages
!__apps__/with-app-dir/app/pages/.keep
__apps__/with-app-dir/app/next-transpile-modules.js
2 changes: 1 addition & 1 deletion src/__tests__/__apps__/pnpm/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "test-npm-basic",
"name": "test-pnpm",
"version": "1.0.0",
"description": "",
"private": "true",
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/__apps__/with-app-dir/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vscode
12 changes: 12 additions & 0 deletions src/__tests__/__apps__/with-app-dir/app/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html>
<head></head>
<body>{children}</body>
</html>
)
}
14 changes: 14 additions & 0 deletions src/__tests__/__apps__/with-app-dir/app/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import { add } from 'shared-ts/utils/calc';
import { Subtitle } from 'shared-ts/components/Subtitle';

const HomePage: React.FC = () => {
return (
<>
<h1>The answer is {add(40, 3)}</h1>
<Subtitle underlined>And this is a subtitle</Subtitle>
</>
);
};

export default HomePage;
5 changes: 5 additions & 0 deletions src/__tests__/__apps__/with-app-dir/app/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
10 changes: 10 additions & 0 deletions src/__tests__/__apps__/with-app-dir/app/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const withTM = require('./next-transpile-modules')(['shared', 'shared-ts', 'shared-ui', 'lodash-es'], { debug: true });

module.exports = withTM({
eslint: {
ignoreDuringBuilds: true,
},
experimental: {
appDir: true,
},
});
29 changes: 29 additions & 0 deletions src/__tests__/__apps__/with-app-dir/app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "test-yarn-workspaces",
"version": "1.0.0",
"description": "",
"private": "true",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"author": "Pierre de la Martinière <pierre.de.la.martiniere@gmail.com>",
"license": "MIT",
"dependencies": {
"lodash-es": "^4.17.21",
"next": "13.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sass": "^1.43.4",
"shared": "^1.0.0",
"shared-ts": "^1.0.0",
"shared-ui": "^1.0.0"
},
"devDependencies": {
"@types/node": "^18.11.7",
"@types/react": "^18.0.24",
"@types/react-dom": "^18.0.8",
"typescript": "^4.8.4"
}
}
36 changes: 36 additions & 0 deletions src/__tests__/__apps__/with-app-dir/app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
]
},
"exclude": [
"node_modules"
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
]
}
9 changes: 9 additions & 0 deletions src/__tests__/__apps__/with-app-dir/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"private": true,
"workspaces": [
"shared",
"shared-ts",
"shared-ui",
"app"
]
}
Loading

0 comments on commit b224849

Please sign in to comment.