Skip to content

Commit

Permalink
extend plugin:cypress/recommended config (#3035)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaMachina authored Feb 24, 2023
1 parent b533a9a commit c4b480e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
6 changes: 1 addition & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,9 @@ module.exports = {
// cypress clashes with jest expect()
{
files: ['**/cypress/**'],
plugins: ['cypress'],
env: {
'cypress/globals': true,
},
extends: 'plugin:cypress/recommended',
},
{
excludedFiles: ['**/cypress/**/*.{js,ts}'],
files: [
'**/__{tests,mocks}__/*.{js,jsx,ts,tsx}',
'**/*.spec.{ts,js.jsx.tsx}',
Expand Down
1 change: 0 additions & 1 deletion packages/graphiql/cypress/e2e/graphql-ws.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ describe('IncrementalDelivery support via fetcher', () => {
it('Expects a subscription to resolve', () => {
cy.visitWithOp({ query: testSubscription, variables: { delay: 0 } });
cy.clickExecuteQuery();
cy.wait(1200);
cy.assertQueryResult(mockSubscriptionSuccess);
});
});
Expand Down
1 change: 0 additions & 1 deletion packages/graphiql/cypress/e2e/init.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ describe('GraphiQL On Initialization', () => {
});
it('Shows the expected error when the schema is invalid', () => {
cy.visit(`/?bad=true`);
cy.wait(200);
cy.get('section.result-window').should(element => {
expect(element.get(0).innerText).to.contain('Names must');
});
Expand Down
3 changes: 1 addition & 2 deletions packages/graphiql/cypress/e2e/keyboard.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('GraphiQL keyboard interactions', () => {
});

it('Does prevent the escape key from being handled outside the editor if closing the autocomplete dialog', () => {
cy.visit('/').wait(3000);
cy.visit('/');
const mockFn = cy.stub().as('escapeHandler');
cy.document().then(doc => {
doc.addEventListener('keydown', event => {
Expand All @@ -28,7 +28,6 @@ describe('GraphiQL keyboard interactions', () => {

cy.get('.graphiql-query-editor textarea')
.type('{\n t', { force: true })
.wait(500)
.type('{esc}');

cy.get('@escapeHandler').should('not.have.been.called');
Expand Down
14 changes: 6 additions & 8 deletions packages/graphiql/cypress/e2e/tabs.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@ describe('Tabs', () => {
cy.get('#graphiql-session-tab-0').should('not.exist');

// Enter a query without operation name
cy.get('.graphiql-query-editor textarea')
.type('{id', { force: true })
.wait(500);
cy.get('.graphiql-query-editor textarea').type('{id', { force: true });

// Run the query
cy.clickExecuteQuery().wait(500);
cy.clickExecuteQuery();

// Open a new tab
cy.get('.graphiql-tab-add').click();

// Enter a query
cy.get('.graphiql-query-editor textarea')
.type('query Foo {image', { force: true })
.wait(500);
cy.get('.graphiql-query-editor textarea').type('query Foo {image', {
force: true,
});
cy.get('#graphiql-session-tab-1').should('have.text', 'Foo');

// Enter variables
Expand All @@ -34,7 +32,7 @@ describe('Tabs', () => {
.type('{"someHeader":"someValue"', { force: true });

// Run the query
cy.clickExecuteQuery().wait(500);
cy.clickExecuteQuery();

// Switch back to the first tab
cy.get('#graphiql-session-tab-0').click();
Expand Down
9 changes: 8 additions & 1 deletion packages/graphiql/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,26 @@ declare namespace Cypress {
| { data: any; hasNext?: boolean }
| { error: any[] }
| { errors: any[] };

interface Chainable {
/**
* Custom command to select DOM element by data-cy attribute.
* @example cy.dataCy('greeting')
*/
dataCy(value: string): Chainable<Element>;

getCy(cyName: string): Chainable<Element>;

clickExecuteQuery(): Chainable<Element>;

visitWithOp(op: Op): Chainable<Element>;

clickPrettify(): Chainable<Element>;

assertHasValues(op: Op): Chainable<Element>;

assertQueryResult(expectedResult: MockResult): Chainable<Element>;

assertLinterMarkWithMessage(
text: string,
severity: 'error' | 'warning',
Expand Down Expand Up @@ -139,7 +147,6 @@ function normalizeWhitespace(str: string) {
Cypress.Commands.add(
'assertLinterMarkWithMessage',
(text, severity, message) => {
cy.wait(100);
cy.contains(text)
.should('have.class', 'CodeMirror-lint-mark')
.and('have.class', `CodeMirror-lint-mark-${severity}`);
Expand Down

0 comments on commit c4b480e

Please sign in to comment.