-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(npm/react): support transpiling typescript files in support (#16197)
* fix: transpile typescript in supportFolder for react-scripts * lint * lint * lint * lint * update package.json deps * Remove yarn lock * inject dev serverg * add circleci reporter Co-authored-by: Barthélémy Ledoux <[email protected]>
- Loading branch information
1 parent
46e9b30
commit 60b217c
Showing
10 changed files
with
103 additions
and
1 deletion.
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
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,7 @@ | ||
{ | ||
"video": false, | ||
"testFiles": "**/*cy-spec.tsx", | ||
"viewportWidth": 500, | ||
"viewportHeight": 800, | ||
"componentFolder": "src" | ||
} |
6 changes: 6 additions & 0 deletions
6
npm/react/examples/react-scripts-typescript/cypress/integration/cy-spec.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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/// <reference types="cypress" /> | ||
describe('integration spec', () => { | ||
it('works', () => { | ||
expect(1).to.equal(1) | ||
}) | ||
}) |
7 changes: 7 additions & 0 deletions
7
npm/react/examples/react-scripts-typescript/cypress/plugins/index.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const injectDevServer = require('@cypress/react/plugins/react-scripts') | ||
|
||
module.exports = (on, config) => { | ||
injectDevServer(on, config) | ||
|
||
return config | ||
} |
9 changes: 9 additions & 0 deletions
9
npm/react/examples/react-scripts-typescript/cypress/support/index.d.ts
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,9 @@ | ||
declare namespace Cypress { | ||
interface Chainable { | ||
/** | ||
* Custom command to select DOM element by data-cy attribute. | ||
* @example cy.dataCy('greeting') | ||
*/ | ||
clickButtonWithText(value: string): Chainable | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
npm/react/examples/react-scripts-typescript/cypress/support/index.ts
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,5 @@ | ||
/// <reference types="cypress" /> | ||
|
||
Cypress.Commands.add('clickButtonWithText', (value: string) => { | ||
return cy.get('button').contains(value).click() | ||
}) |
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,18 @@ | ||
{ | ||
"private": true, | ||
"scripts": { | ||
"cy:open": "node ../../../../scripts/cypress open-ct", | ||
"start": "react-scripts start", | ||
"test": "node ../../../../scripts/cypress run-ct" | ||
}, | ||
"devDependencies": { | ||
"@cypress/react": "file:../../dist", | ||
"@types/react": "^17.0.0", | ||
"@types/react-dom": "^17.0.0", | ||
"cypress-circleci-reporter": "0.2.0", | ||
"react": "^17.0.1", | ||
"react-dom": "^17.0.1", | ||
"react-scripts": "4.0.3", | ||
"typescript": "^4.2.3" | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
npm/react/examples/react-scripts-typescript/src/App.cy-spec.tsx
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,16 @@ | ||
/// <reference path="../cypress/support/index.d.ts" /> | ||
|
||
import React from 'react' | ||
import { mount } from '@cypress/react' | ||
|
||
it('works', () => { | ||
const click = cy.stub() | ||
const App = () => { | ||
return (<button onClick={click}>Button!</button>) | ||
} | ||
|
||
mount(<App />) | ||
cy.clickButtonWithText('Button!').then(() => { | ||
expect(click).to.have.been.calledWith() | ||
}) | ||
}) |
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,29 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": [ | ||
"dom", | ||
"dom.iterable", | ||
"esnext" | ||
], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"noEmit": true, | ||
"jsx": "react-jsx", | ||
"types": [ | ||
"cypress" | ||
] | ||
}, | ||
"include": [ | ||
"src" | ||
] | ||
} |
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
60b217c
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.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
60b217c
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.
AppVeyor has built the
win32 ia32
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
60b217c
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.
AppVeyor has built the
win32 x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
60b217c
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.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally: