This file contains hidden or 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
import user from './user' | |
describe('user', () => { | |
// before each test | |
beforeEach(() => { | |
// spy on the "isValid" function on the "user" object | |
jest.spyOn(user, 'isValid'); | |
}) | |
This file contains hidden or 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
it('returns an object containing all users', done => { | |
// create and configure the fake server to replace the native network call | |
const server = sinon.createFakeServer() | |
server.respondWith('GET', '/users', [ | |
200, | |
{ 'Content-Type': 'application/json' }, | |
'[{ "id": 1, "name": "Gwen" }, { "id": 2, "name": "John" }]' | |
]) |
This file contains hidden or 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
it('renders correctly', () => { | |
// create an instance of the Link component with page and child text | |
const linkInstance = ( | |
<Link page="http://www.facebook.com">Facebook</Link> | |
) | |
// create a data snapshot of the component | |
const tree = renderer.create(linkInstance).toJSON() | |
This file contains hidden or 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
exports[`renders correctly 1`] = ` | |
<a | |
className="normal" | |
href="http://www.facebook.com" | |
onMouseEnter={[Function]} | |
onMouseLeave={[Function]} | |
> | |
</a> | |
`; |
This file contains hidden or 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
// "describe" is in the global scope already | |
// so no these require lines are **not required**: | |
// import { describe } from 'jest' | |
// import { describe } from 'jasmine' | |
describe('calculator', function() { | |
... | |
}) |
This file contains hidden or 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
import { Selector } from 'testcafe'; | |
fixture `Getting Started` | |
.page `https://devexpress.github.io/testcafe/example` | |
// Own testing structure | |
test('My first test', async t => { | |
await t | |
.typeText('#developer-name', 'John Smith') | |
.click('#submit-button') |
This file contains hidden or 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
describe('My First Cypress Test', function() { | |
it("Gets, types and asserts", function() { | |
cy.visit('https://example.cypress.io') | |
cy.contains('type').click() | |
// Should be on a new URL which includes '/commands/actions' | |
cy.url().should('include', '/commands/actions') | |
// Get an input, type into it and verify that the value has been updated |
This file contains hidden or 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
Feature: A reader can share an article to social networks | |
As a reader | |
I want to share articles | |
So that I can notify my friends about an article I liked | |
Scenario: An article was opened | |
Given I'm inside an article | |
When I share the article | |
Then the article should change to a "shared" state | |
This file contains hidden or 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
describe('login form', () => { | |
before(() => { | |
return driver.navigate().to('http://path.to.test.app/') | |
}) | |
it('autocompletes the name field', () => { | |
driver | |
.findElement(By.css('.autocomplete')) | |
.sendKeys('John') |
This file contains hidden or 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
Scenario('login with generated password', async (I) => { | |
I.fillField('email', '[email protected]'); | |
I.click('Generate Password'); | |
const password = await I.grabTextFrom('#password'); | |
I.click('Login'); | |
I.fillField('email', '[email protected]'); | |
I.fillField('password', password); | |
I.click('Log in!'); | |
I.see('Hello, Miles'); | |
}); |