-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Conditionally test ESLint rules (#31258)
- Loading branch information
Showing
6 changed files
with
89 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
src/pages/anonymous-arrow.js | ||
src/pages/anonymous-arrow-two.js |
34 changes: 31 additions & 3 deletions
34
...ts/development-runtime/cypress/integration/eslint-rules/limited-exports-page-templates.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,44 @@ | ||
before(() => { | ||
cy.exec( | ||
`npm run update -- --file src/pages/eslint-rules/limited-exports-page-templates.js --restore` | ||
) | ||
}) | ||
|
||
after(() => { | ||
cy.exec( | ||
`npm run update -- --file src/pages/eslint-rules/limited-exports-page-templates.js --restore` | ||
) | ||
}) | ||
|
||
const errorPlaceholder = `// export function notAllowed() {}` | ||
const errorReplacement = `export function notAllowed() {}` | ||
|
||
describe(`limited-exports-page-templates`, () => { | ||
it(`should log warning to console for invalid export`, () => { | ||
beforeEach(() => { | ||
cy.visit( | ||
`/eslint-rules/limited-exports-page-templates` | ||
).waitForRouteChange() | ||
}) | ||
|
||
it(`should initially not log to console`, () => { | ||
cy.get(`@hmrConsoleLog`).should( | ||
`not.be.calledWithMatch`, | ||
/13:1 {2}warning {2}In page templates only a default export of a valid React component and the named export of a page query is allowed./i | ||
) | ||
}) | ||
it(`should log warning to console for invalid export`, () => { | ||
cy.exec( | ||
`npm run update -- --file src/pages/eslint-rules/limited-exports-page-templates.js --replacements "${errorPlaceholder}:${errorReplacement}" --exact` | ||
) | ||
cy.reload() | ||
|
||
cy.get(`@hmrConsoleLog`).should( | ||
`be.calledWithMatch`, | ||
/15:1 warning In page templates only a default export of a valid React component and the named export of a page query is allowed./i | ||
/13:1 {2}warning {2}In page templates only a default export of a valid React component and the named export of a page query is allowed./i | ||
) | ||
cy.get(`@hmrConsoleLog`).should( | ||
`not.be.calledWithMatch`, | ||
/17:1 warning In page templates only a default export of a valid React component and the named export of a page query is allowed./i | ||
/15:1 {2}warning {2}In page templates only a default export of a valid React component and the named export of a page query is allowed./i | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters