Skip to content

Commit

Permalink
Failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
FelipeLahti committed Oct 6, 2021
1 parent ab5fd70 commit 7e7136d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
# we have already installed everything
install: false
# to run component tests we need to use "cypress run-ct"
command: yarn cypress run-ct
command: npx cypress run-ct
13 changes: 2 additions & 11 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
import logo from './logo.svg';
import './App.css';
import { calculate } from './anModule';

function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
<p>{calculate()}</p>
</header>
</div>
);
Expand Down
11 changes: 9 additions & 2 deletions src/App.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
import * as React from 'react'
import { mount } from '@cypress/react'
import App from './App'
import * as anModule from './anModule'

it('renders learn react link', () => {
it('renders total is 10', () => {
mount(<App />)
cy.contains(/learn react/i)
cy.contains(/total is 10/i)
})

it('renders total is mocked value', () => {
cy.stub(anModule, 'calculate').returns('total is 25')
mount(<App />)
cy.contains(/total is 25/i)
})
5 changes: 5 additions & 0 deletions src/anModule.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


export const calculate = () => {
return "total is 10"
}

0 comments on commit 7e7136d

Please sign in to comment.