From a7a23f77d00226d1124b16212459aa87beb359bf Mon Sep 17 00:00:00 2001 From: meteorlxy Date: Mon, 19 Feb 2024 14:08:45 +0800 Subject: [PATCH] test: run hmr restore tasks in after hook --- e2e/tests/hmr/frontmatter.cy.ts | 4 ++++ e2e/tests/hmr/navigation.cy.ts | 5 +++++ e2e/tests/hmr/title.cy.ts | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/e2e/tests/hmr/frontmatter.cy.ts b/e2e/tests/hmr/frontmatter.cy.ts index 275b6232e5..ec004b6603 100644 --- a/e2e/tests/hmr/frontmatter.cy.ts +++ b/e2e/tests/hmr/frontmatter.cy.ts @@ -1,4 +1,8 @@ if (Cypress.env('E2E_COMMAND') === 'dev') { + after(() => { + cy.task('hmr:frontmatter:restore') + }) + it('should update frontmatter correctly', () => { cy.visit('/hmr/frontmatter.html') cy.get('.e2e-theme-content #rendered-foo + p').should( diff --git a/e2e/tests/hmr/navigation.cy.ts b/e2e/tests/hmr/navigation.cy.ts index f9f5ddf918..bc1ef90ff3 100644 --- a/e2e/tests/hmr/navigation.cy.ts +++ b/e2e/tests/hmr/navigation.cy.ts @@ -1,4 +1,9 @@ if (Cypress.env('E2E_COMMAND') === 'dev') { + after(() => { + cy.task('hmr:title:restore') + cy.task('hmr:frontmatter:restore') + }) + it('should update title and frontmatter correctly after navigation', () => { cy.visit('/hmr/title.html') cy.title().should('include', 'HMR Title') diff --git a/e2e/tests/hmr/title.cy.ts b/e2e/tests/hmr/title.cy.ts index c974d4740f..00f9a3d4ca 100644 --- a/e2e/tests/hmr/title.cy.ts +++ b/e2e/tests/hmr/title.cy.ts @@ -1,4 +1,8 @@ if (Cypress.env('E2E_COMMAND') === 'dev') { + after(() => { + cy.task('hmr:title:restore') + }) + it('should update title correctly', () => { cy.visit('/hmr/title.html') cy.title().should('include', 'HMR Title')