Skip to content

Commit

Permalink
chore(crwa): update e2e test to handle yarn install patch (#9862)
Browse files Browse the repository at this point in the history
This PR fixes the CRWA e2e tests after the functionality introduced in
#9861.

For now I'm skipping `yarn install` since it's prone to timeouts in CI,
and the subsequent step, generating types, is also flakey since `yarn
pack` seems to skip the `.yarnrc.yml` which is necessary for configuring
a proper install.
  • Loading branch information
jtoar committed Jan 21, 2024
1 parent 6f38084 commit f447adb
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/create-redwood-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"scripts": {
"build": "node ./scripts/build.js",
"build:pack": "yarn pack -o create-redwood-app.tgz",
"build:pack": "node ./scripts/buildPack.js",
"build:watch": "nodemon --watch src --ignore dist,template --exec \"yarn build\"",
"prepublishOnly": "NODE_ENV=production yarn build",
"set-up-test-project": "node ./scripts/setUpTestProject.js",
Expand Down
31 changes: 31 additions & 0 deletions packages/create-redwood-app/scripts/buildPack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* eslint-env node */

import { fileURLToPath } from 'node:url'

import { cd, path, within, $ } from 'zx'

const tsTemplatePath = fileURLToPath(
new URL('../templates/ts', import.meta.url)
)
const jsTemplatePath = fileURLToPath(
new URL('../templates/js', import.meta.url)
)

await within(async () => {
cd(tsTemplatePath)

await $`touch yarn.lock`
await $`yarn`
})

await within(async () => {
cd(jsTemplatePath)

await $`touch yarn.lock`
await $`yarn`
})

await $`yarn pack -o create-redwood-app.tgz`

await $`rm ${path.join(tsTemplatePath, 'yarn.lock')}`
await $`rm ${path.join(jsTemplatePath, 'yarn.lock')}`
4 changes: 2 additions & 2 deletions packages/create-redwood-app/templates/js/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"react-dom": "0.0.0-experimental-e5205658f-20230913"
},
"devDependencies": {
"@redwoodjs/vite": "6.0.7",
"@types/react": "18.2.37",
"@types/react-dom": "18.2.15",
"@redwoodjs/vite": "6.0.7"
"@types/react-dom": "18.2.15"
}
}
4 changes: 2 additions & 2 deletions packages/create-redwood-app/templates/ts/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"react-dom": "0.0.0-experimental-e5205658f-20230913"
},
"devDependencies": {
"@redwoodjs/vite": "6.0.7",
"@types/react": "18.2.37",
"@types/react-dom": "18.2.15",
"@redwoodjs/vite": "6.0.7"
"@types/react-dom": "18.2.15"
}
}
11 changes: 8 additions & 3 deletions packages/create-redwood-app/tests/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ describe('create-redwood-app', () => {
})

test('--yes, -y', async () => {
const p = await $`yarn create-redwood-app ./redwood-app --yes`
// Running `yarn install` in Jest test times out and the subsequent step,
// generating types, is also flakey since `yarn pack` seems to skip `.yarnrc.yml`
// which is necessary for configuring a proper install.
const p =
await $`yarn create-redwood-app ./redwood-app --no-yarn-install --yes`

expect(p.exitCode).toEqual(0)
expect(p.stdout).toMatchInlineSnapshot(`
Expand All @@ -66,10 +70,11 @@ describe('create-redwood-app', () => {
[?25h✔ Creating your Redwood app in ./redwood-app based on command line argument
✔ Using TypeScript based on command line flag
✔ Will initialize a git repo based on command line flag
✔ Will run yarn install based on command line flag
✔ Will not run yarn install based on command line flag
[?25l⠋ Creating project files
[?25h[?25l✔ Project files created
[?25h[?25l⠋ Initializing a git repo
[?25hℹ Skipped yarn install step
[?25l⠋ Initializing a git repo
[?25h[?25l✔ Initialized a git repo with commit message "Initial commit"
[?25h
Thanks for trying out Redwood!
Expand Down
2 changes: 1 addition & 1 deletion packages/create-redwood-app/tests/e2e_prompts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cd $projectPath

set projectDirectory "redwood-app-prompt-test"

spawn yarn create-redwood-app
spawn yarn create-redwood-app --no-yarn-install

expect "Where would you like to create your Redwood app?"
send "$projectDirectory\n"
Expand Down
2 changes: 1 addition & 1 deletion packages/create-redwood-app/tests/e2e_prompts_git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cd $projectPath

set projectDirectory "redwood-app-prompt-git-test"

spawn yarn create-redwood-app --git
spawn yarn create-redwood-app --no-yarn-install --git

expect "Where would you like to create your Redwood app?"
send "$projectDirectory\n"
Expand Down
2 changes: 1 addition & 1 deletion packages/create-redwood-app/tests/e2e_prompts_m.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cd $projectPath

set projectDirectory "redwood-app-prompt-m-test"

spawn yarn create-redwood-app -m "first"
spawn yarn create-redwood-app --no-yarn-install -m "first"

expect "Where would you like to create your Redwood app?"
send "$projectDirectory\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cd $projectPath

set projectDirectory "redwood-app-prompt-node-greater-test"

spawn yarn create-redwood-app
spawn yarn create-redwood-app --no-yarn-install

expect "How would you like to proceed?"
# ❯ Override error and continue install
Expand Down
2 changes: 1 addition & 1 deletion packages/create-redwood-app/tests/e2e_prompts_node_less.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cd $projectPath

set projectDirectory "redwood-app-prompt-node-less-test"

spawn yarn create-redwood-app
spawn yarn create-redwood-app --no-yarn-install

expect eof
catch wait result
Expand Down
2 changes: 1 addition & 1 deletion packages/create-redwood-app/tests/e2e_prompts_overwrite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set projectDirectory "redwood-app-prompt-overwrite-test"
exec mkdir $projectDirectory
exec touch $projectDirectory/README.md

spawn yarn create-redwood-app
spawn yarn create-redwood-app --no-yarn-install

expect "Where would you like to create your Redwood app?"
send "$projectDirectory\n"
Expand Down
2 changes: 1 addition & 1 deletion packages/create-redwood-app/tests/e2e_prompts_ts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cd $projectPath

set projectDirectory "redwood-app-prompt-ts-test"

spawn yarn create-redwood-app --ts
spawn yarn create-redwood-app --no-yarn-install --ts

expect "Where would you like to create your Redwood app?"
send "$projectDirectory\n"
Expand Down

0 comments on commit f447adb

Please sign in to comment.