Created
November 22, 2018 12:15
-
-
Save barsumek/b63ae5be215e5bdb25978d65f924757d to your computer and use it in GitHub Desktop.
Detox your GraphQL: Working test with mocked server
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
/* eslint-env detox/detox, mocha */ | |
const { defaultPokemon, maxLvlPokemon } = require("../graphql/mocks/pokemon"); | |
const { date } = require("../graphql/mocks/scalars"); | |
const { | |
startGraphQLServer, | |
stopGraphQLServer | |
} = require("../graphql/mockedGraphQLServer"); | |
describe("Test Pokemon screen", () => { | |
beforeEach(async () => { | |
await device.reloadReactNative(); | |
}); | |
afterEach(async () => { | |
await stopGraphQLServer(); | |
}); | |
it("Display MaxLvl if the pokemon has maximum level.", async () => { | |
await startGraphQLServer({ ...maxLvlPokemon, ...date }); | |
await expect(element(by.id("pokemonButton"))).toBeVisible(); | |
await element(by.id("pokemonButton")).tap(); | |
await expect(element(by.text("Level: MaxLvl"))).toBeVisible(); | |
}); | |
it("Display level if the pokemon does not have maximum level.", async () => { | |
await startGraphQLServer({ ...defaultPokemon, ...date }); | |
await expect(element(by.id("pokemonButton"))).toBeVisible(); | |
await element(by.id("pokemonButton")).tap(); | |
await expect(element(by.text("Level: 10"))).toBeVisible(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment