-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: configure proper pages directory for next application #18009
Conversation
Thanks for taking the time to open a PR!
|
Test summaryRun details
View run in Cypress Dashboard ➡️ Flakiness
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, but we need to make sure that our code is written ts-first. If you have a sec to convert the new Javascript files into Typescript, that would be super.
npm/react/package.json
Outdated
@@ -12,6 +12,9 @@ | |||
"cy:run:debug": "node --inspect-brk ../../scripts/start.js --component-testing --run-project ${PWD}", | |||
"pretest": "yarn transpile", | |||
"test": "yarn cy:run", | |||
"yarn": "yarn test-unit && yarn test-component", | |||
"test-unit": "mocha test/**/*.spec.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"test-unit": "mocha test/**/*.spec.js", | |
"test-unit": "mocha test/**/*.spec.*", |
return projectRoot | ||
} | ||
|
||
module.exports.findPagesDir = findPagesDir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, in TS this would be
export function findPagesDir() { /* ... */ }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job figuring this out - just need some TS and to clarify what the yarn
command is for (yarn
does not seem like a great name for a script in package.json).
npm/react/package.json
Outdated
@@ -12,6 +12,9 @@ | |||
"cy:run:debug": "node --inspect-brk ../../scripts/start.js --component-testing --run-project ${PWD}", | |||
"pretest": "yarn transpile", | |||
"test": "yarn cy:run", | |||
"yarn": "yarn test-unit && yarn test-component", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this step supposed to be called yarn
? This doesn't seem correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I meant to replace line 14 with "test": "yarn test-unit && yarn test-component",
@lmiller1990 @JessicaSachs Is the
There are more drastic changes we could make but I didn't want to change too much just for a small bug fix. Thoughts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. No, Appveyor sometimes doesn't retrigger. It's usually fine, though.
Seems the build is broken. You should be able to reproduce locally with |
3452a80
to
9445ee4
Compare
@lmiller1990 Looks like windows didn't like the glob pattern for tsc cli. I added a tsconfig for plugins so it should be good now. |
User facing changelog
NA
Additional details
Our Next.js plugin was not pointing to the correct pagesDir, causing errors to be thrown if files under projectRoot did not follow the pages export convention. This PR sets the
pagesDir
by looking for either{root}/pages
or{root}/src/pages
(Next.js conventions) and falling back to{root}
if not found.I tested this by checking out https://github.com/cypress-io/cypress-component-testing-examples and:
cd ./create-next-app
yarn
mkdir -p ./src/components
echo "export const HelloWorld = () => 'Hello World!'" >> ./src/components/HelloWorld.js
echo "export * from './HelloWorld'" >> ./src/components/index.js
import { HelloWorld } from '../src/components'
to./pages/index.js
npx cypress run-ct
and see that it fails (You can run DEBUG=* npx cypress run-ct to see logs)plugins
folder from this branch (or entire built package) into./node_modules/@cypress/react
npx cypress run-ct
and see that it passesHow has the user experience changed?
NA
PR Tasks
cypress-documentation
?type definitions
?cypress.schema.json
?