From acc6abfb540c77b153e9dd36d53dd85139b20ef4 Mon Sep 17 00:00:00 2001 From: mutoe Date: Sat, 27 Feb 2021 00:18:02 +0800 Subject: [PATCH] fix: adaptive cypress 6 intercept method --- cypress/integration/home.spec.js | 7 +++---- cypress/integration/like-follow.spec.js | 11 +++++------ cypress/integration/login-logout.spec.js | 9 ++++----- cypress/integration/register.spec.js | 11 +++++------ cypress/integration/tag.spec.js | 7 +++---- 5 files changed, 20 insertions(+), 25 deletions(-) diff --git a/cypress/integration/home.spec.js b/cypress/integration/home.spec.js index ce62cd1..765a86c 100644 --- a/cypress/integration/home.spec.js +++ b/cypress/integration/home.spec.js @@ -1,9 +1,8 @@ describe('View the homepage', () => { beforeEach(() => { - cy.server() - cy.route2('GET', /articles\?tag=butt/, { fixture: 'article_of_tag' }).as('article_of_tag') - cy.route2('GET', /articles/, { fixture: 'articles.json' }).as('getArticles') - cy.route2('GET', /tags/, { fixture: 'tags.json' }).as('getTags') + cy.intercept('GET', /articles\?tag=butt/, { fixture: 'article_of_tag' }).as('article_of_tag') + cy.intercept('GET', /articles/, { fixture: 'articles.json' }).as('getArticles') + cy.intercept('GET', /tags/, { fixture: 'tags.json' }).as('getTags') cy.visit('/') }) diff --git a/cypress/integration/like-follow.spec.js b/cypress/integration/like-follow.spec.js index cb982aa..2a17269 100644 --- a/cypress/integration/like-follow.spec.js +++ b/cypress/integration/like-follow.spec.js @@ -1,10 +1,9 @@ describe('test for like-follow', () => { beforeEach(() => { - cy.server() - cy.route2('GET', /articles\?tag=butt/, { fixture: 'article_of_tag' }).as('article_of_tag') - cy.route2('GET', /articles\?/, { fixture: 'articles.json' }).as('getArticles') - cy.route2('GET', /articles\//, { fixture: 'article.json' }).as('getArticle') - cy.route2('GET', /tags/, { fixture: 'tags.json' }).as('getTags') + cy.intercept('GET', /articles\?tag=butt/, { fixture: 'article_of_tag' }).as('article_of_tag') + cy.intercept('GET', /articles\?/, { fixture: 'articles.json' }).as('getArticles') + cy.intercept('GET', /articles\//, { fixture: 'article.json' }).as('getArticle') + cy.intercept('GET', /tags/, { fixture: 'tags.json' }).as('getTags') cy.visit('/') }) @@ -17,7 +16,7 @@ describe('test for like-follow', () => { .should('contain', 'login') cy.get('h1.text-xs-center') - .should('contain.text', ' Sign in ') + .should('contain.text', 'Sign in') }) it('login:like articles', () => { diff --git a/cypress/integration/login-logout.spec.js b/cypress/integration/login-logout.spec.js index 2dae2b2..d6fb69c 100644 --- a/cypress/integration/login-logout.spec.js +++ b/cypress/integration/login-logout.spec.js @@ -1,10 +1,9 @@ describe('test for login', () => { beforeEach(() => { - cy.server() - cy.route2('GET', /articles\?tag=butt/, { fixture: 'article_of_tag' }).as('article_of_tag') - cy.route2('GET', /articles\?/, { fixture: 'articles.json' }).as('getArticles') - cy.route2('GET', /articles\//, { fixture: 'article.json' }).as('getArticle') - cy.route2('GET', /tags/, { fixture: 'tags.json' }).as('getTags') + cy.intercept('GET', /articles\?tag=butt/, { fixture: 'article_of_tag' }).as('article_of_tag') + cy.intercept('GET', /articles\?/, { fixture: 'articles.json' }).as('getArticles') + cy.intercept('GET', /articles\//, { fixture: 'article.json' }).as('getArticle') + cy.intercept('GET', /tags/, { fixture: 'tags.json' }).as('getTags') cy.visit('/') }) diff --git a/cypress/integration/register.spec.js b/cypress/integration/register.spec.js index 6b493c6..2ee69de 100644 --- a/cypress/integration/register.spec.js +++ b/cypress/integration/register.spec.js @@ -1,11 +1,10 @@ describe('test for register', () => { beforeEach(() => { - cy.server() - cy.route2('POST', /users/, { fixture: 'register.json' }).as('register') - cy.route2('GET', /articles\?tag=butt/, { fixture: 'article_of_tag' }).as('article_of_tag') - cy.route2('GET', /articles\?/, { fixture: 'articles.json' }).as('getArticles') - cy.route2('GET', /articles\//, { fixture: 'article.json' }).as('getArticle') - cy.route2('GET', /tags/, { fixture: 'tags.json' }).as('getTags') + cy.intercept('POST', /users/, { fixture: 'register.json' }).as('register') + cy.intercept('GET', /articles\?tag=butt/, { fixture: 'article_of_tag' }).as('article_of_tag') + cy.intercept('GET', /articles\?/, { fixture: 'articles.json' }).as('getArticles') + cy.intercept('GET', /articles\//, { fixture: 'article.json' }).as('getArticle') + cy.intercept('GET', /tags/, { fixture: 'tags.json' }).as('getTags') cy.visit('/') }) diff --git a/cypress/integration/tag.spec.js b/cypress/integration/tag.spec.js index 2c674bb..af58a0d 100644 --- a/cypress/integration/tag.spec.js +++ b/cypress/integration/tag.spec.js @@ -1,9 +1,8 @@ describe('test for tag', () => { beforeEach(() => { - cy.server() - cy.route2('GET', /articles\?tag=butt/, { fixture: 'article_of_tag' }).as('article_of_tag') - cy.route2('GET', /articles/, { fixture: 'articles.json' }).as('getArticles') - cy.route2('GET', /tags/, { fixture: 'tags.json' }).as('getTags') + cy.intercept('GET', /articles\?tag=butt/, { fixture: 'article_of_tag' }).as('article_of_tag') + cy.intercept('GET', /articles/, { fixture: 'articles.json' }).as('getArticles') + cy.intercept('GET', /tags/, { fixture: 'tags.json' }).as('getTags') cy.visit('/') })