Skip to content

Commit 3ea5d6d

Browse files
committed
fix: test cases
1 parent 8fc63ec commit 3ea5d6d

File tree

6 files changed

+120
-52
lines changed

6 files changed

+120
-52
lines changed

.github/workflows/create-next-app-with-gluestack-ui.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ on:
99
branches:
1010
- main
1111
- development
12-
schedule:
13-
- cron: "0 */4 * * *"
1412

1513
jobs:
1614
test:
@@ -49,4 +47,4 @@ jobs:
4947
with:
5048
channel_id: C05HK6WEE56
5149
status: FAILED by @${{ github.actor}}
52-
color: danger
50+
color: danger
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
name: Create Next App with Gluestack UI
1+
name: Create Next App with Gluestack UI (isProduction | @latest)
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
branches:
9-
- main
104
schedule:
115
- cron: "0 */4 * * *"
126

@@ -24,12 +18,18 @@ jobs:
2418
- name: Install dependencies (prevent updates to lock file)
2519
working-directory: ${{ env.working-directory }}
2620
run: yarn
27-
- name: Building
21+
- name: Testing Production
2822
working-directory: ${{ env.working-directory }}
29-
run: yarn build
30-
- name: Testing
31-
working-directory: ${{ env.working-directory }}
32-
run: yarn test
23+
run: yarn test:production
24+
- name: Notify Success
25+
if: success()
26+
env:
27+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
28+
uses: voxmedia/github-action-slack-notify-build@v1
29+
with:
30+
channel_id: C05HK6WEE56
31+
status: SUCCESS by @${{ github.actor}}
32+
color: good
3333
- name: Notify Failure
3434
if: failure()
3535
env:
@@ -38,4 +38,4 @@ jobs:
3838
with:
3939
channel_id: C05HGN9LFV0
4040
status: FAILED by @${{ github.actor}}, Notify <@U047HGWBG>
41-
color: danger
41+
color: danger
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release create-next-app-with-gluestack-ui
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref || github.run_id }}
9+
10+
jobs:
11+
release:
12+
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged
13+
name: Publish version
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout Repo
17+
uses: actions/checkout@v3
18+
19+
- name: Set up Node.js v18.x
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: "18.x"
23+
24+
- name: Install dependencies
25+
run: |
26+
yarn
27+
yarn build
28+
29+
# - name: Create Release Pull Request or Publish to npm
30+
# id: changesets
31+
# uses: changesets/action@v1
32+
# with:
33+
# publish: yarn release
34+
# env:
35+
# GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
36+
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
37+
38+
- name: Post to a Slack channel
39+
id: slack
40+
if: steps.changesets.outputs.published == 'true'
41+
uses: slackapi/slack-github-action@v1.23.0
42+
with:
43+
channel-id: C05H3MUMPN3
44+
# slack-message: "A new package was published in ${{ github.event.repository.name }}!\n${{ toJSON(steps.changesets.outputs.publishedPackages) }}"
45+
slack-message: "A new package was published in ${{ github.event.repository.name }}!
46+
color: good
47+
env:
48+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const request = require('supertest');
4+
const { join } = require('path');
5+
const {
6+
cleanUpPort,
7+
startProject,
8+
createProject,
9+
cleanAppDirectory,
10+
} = require('./utils');
11+
12+
const APP_NAME = `my-app-with-page-router`;
13+
const nextAppRootDirectory = join(__dirname, '../apps');
14+
const nextAppPath = join(__dirname, '../apps', APP_NAME);
15+
const options = '--page';
16+
17+
const NEXT_PORT = '3040';
18+
const nextAppUrl = `http://localhost:${NEXT_PORT}`;
19+
20+
const isProduction = process.argv.includes('--isProduction=true');
21+
22+
describe('Create Next.js app with page router:', () => {
23+
let appProcess;
24+
beforeAll(async () => {
25+
cleanUpPort(nextAppRootDirectory, NEXT_PORT);
26+
}, 200000);
27+
28+
it('Create a Next.js app with npx', async () => {
29+
await createProject(nextAppRootDirectory, APP_NAME, options, isProduction);
30+
const appPath = path.join(nextAppRootDirectory, APP_NAME);
31+
expect(fs.existsSync(appPath)).toBe(true);
32+
console.log('✅️ project folder is created');
33+
}, 200000);
34+
35+
it('Start and check if Next.js app is running', async () => {
36+
if (fs.existsSync(nextAppPath)) {
37+
appProcess = await startProject(nextAppPath, NEXT_PORT);
38+
const response = await request(nextAppUrl).get('/');
39+
const responseBody = response.text;
40+
expect(responseBody.includes('Get started by editing')).toBe(true);
41+
}
42+
}, 50000);
43+
44+
afterAll(() => {
45+
cleanAppDirectory(nextAppRootDirectory, APP_NAME);
46+
if (appProcess) {
47+
appProcess.kill();
48+
}
49+
});
50+
});
Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<testsuites name="jest tests" tests="4" failures="2" errors="0" time="118.047">
3-
<testsuite name="Create Next.js app with page router:" errors="0" failures="1" skipped="0" timestamp="2023-07-18T11:33:40" time="116.231" tests="2">
4-
<testcase classname="Create Next.js app with page router: Create a Next.js app with npx" name="Create Next.js app with page router: Create a Next.js app with npx" time="64.934">
2+
<testsuites name="jest tests" tests="4" failures="0" errors="0" time="106.606">
3+
<testsuite name="Create Next.js app with page router:" errors="0" failures="0" skipped="0" timestamp="2023-07-18T12:22:49" time="96.469" tests="2">
4+
<testcase classname="Create Next.js app with page router: Create a Next.js app with npx" name="Create Next.js app with page router: Create a Next.js app with npx" time="53.128">
55
</testcase>
6-
<testcase classname="Create Next.js app with page router: Start and check if Next.js app is running" name="Create Next.js app with page router: Start and check if Next.js app is running" time="50.002">
7-
<failure>Error: thrown: &quot;Exceeded timeout of 50000 ms for a test.
8-
Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout.&quot;
9-
at it (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/__tests__/integration/next-page-router.test.js:35:3)
10-
at _dispatchDescribe (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/node_modules/jest-circus/build/index.js:91:26)
11-
at describe (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/node_modules/jest-circus/build/index.js:55:5)
12-
at Object.describe (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/__tests__/integration/next-page-router.test.js:21:1)
13-
at Runtime._execModule (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/node_modules/jest-runtime/build/index.js:1430:24)
14-
at Runtime._loadModule (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/node_modules/jest-runtime/build/index.js:1013:12)
15-
at Runtime.requireModule (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/node_modules/jest-runtime/build/index.js:873:12)
16-
at jestAdapter (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:77:13)
17-
at processTicksAndRejections (node:internal/process/task_queues:95:5)
18-
at runTestInternal (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/node_modules/jest-runner/build/runTest.js:367:16)
19-
at runTest (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/node_modules/jest-runner/build/runTest.js:444:34)
20-
at Object.worker (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/node_modules/jest-runner/build/testWorker.js:106:12)</failure>
6+
<testcase classname="Create Next.js app with page router: Start and check if Next.js app is running" name="Create Next.js app with page router: Start and check if Next.js app is running" time="25.085">
217
</testcase>
228
</testsuite>
23-
<testsuite name="Create Next.js app with app router:" errors="0" failures="1" skipped="0" timestamp="2023-07-18T11:33:40" time="117.261" tests="2">
24-
<testcase classname="Create Next.js app with app router: Create a Next.js app with npx" name="Create Next.js app with app router: Create a Next.js app with npx" time="65.79">
9+
<testsuite name="Create Next.js app with app router:" errors="0" failures="0" skipped="0" timestamp="2023-07-18T12:22:49" time="106.017" tests="2">
10+
<testcase classname="Create Next.js app with app router: Create a Next.js app with npx" name="Create Next.js app with app router: Create a Next.js app with npx" time="53.438">
2511
</testcase>
26-
<testcase classname="Create Next.js app with app router: Start and check if Next.js app is running" name="Create Next.js app with app router: Start and check if Next.js app is running" time="50.003">
27-
<failure>Error: thrown: &quot;Exceeded timeout of 50000 ms for a test.
28-
Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout.&quot;
29-
at it (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/__tests__/integration/next-app-router.test.js:35:3)
30-
at _dispatchDescribe (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/node_modules/jest-circus/build/index.js:91:26)
31-
at describe (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/node_modules/jest-circus/build/index.js:55:5)
32-
at Object.describe (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/__tests__/integration/next-app-router.test.js:22:1)
33-
at Runtime._execModule (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/node_modules/jest-runtime/build/index.js:1430:24)
34-
at Runtime._loadModule (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/node_modules/jest-runtime/build/index.js:1013:12)
35-
at Runtime.requireModule (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/node_modules/jest-runtime/build/index.js:873:12)
36-
at jestAdapter (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:77:13)
37-
at processTicksAndRejections (node:internal/process/task_queues:95:5)
38-
at runTestInternal (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/node_modules/jest-runner/build/runTest.js:367:16)
39-
at runTest (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/node_modules/jest-runner/build/runTest.js:444:34)
40-
at Object.worker (/Users/suraj/Sites/projects/gluestack/gluestack-ui-cli/packages/create-next-app-with-gluestack-ui/node_modules/jest-runner/build/testWorker.js:106:12)</failure>
12+
<testcase classname="Create Next.js app with app router: Start and check if Next.js app is running" name="Create Next.js app with app router: Start and check if Next.js app is running" time="32.663">
4113
</testcase>
4214
</testsuite>
4315
</testsuites>

packages/create-next-app-with-gluestack-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"prepare": "tsc",
2828
"test": "jest",
2929
"test:production": "jest --isProduction=true",
30-
"dev": "yarn build && node dist/index.js"
30+
"dev": "node dist/index.js"
3131
},
3232
"husky": {
3333
"hooks": {

0 commit comments

Comments
 (0)