hongbo-miao/hongbomiao.com

View on GitHub
web-cypress/cypress/e2e/Home.cy.ts

Summary

Maintainability
A
0 mins
Test Coverage
describe('Home', () => {
  const { domain, serverPort, webPort } = Cypress.env();

  it('render Home', () => {
    cy.visit(`${domain}:${webPort}`);
    cy.get('.container').contains('Making magic happen');
  });

  it('receive GraphQL meQuery data', () => {
    const query = `
      query Me {
        me {
          name
          bio
        }
      }
    `;

    cy.request('POST', `${domain}:${serverPort}/graphql`, {
      query,
    }).then((res) => {
      expect(res).property('status').to.equal(200);
      expect(res)
        .property('body')
        .to.eql({
          data: {
            me: {
              name: 'Hongbo Miao',
              bio: 'Making magic happen',
            },
          },
        });
    });
  });
});