diff --git a/cypress/integration/4-step-by-step-tests/step-by-step-journey.cypress.js b/cypress/integration/4-step-by-step-tests/step-by-step-journey.cypress.js index 5e9f9c0861..5a808f1146 100644 --- a/cypress/integration/4-step-by-step-tests/step-by-step-journey.cypress.js +++ b/cypress/integration/4-step-by-step-tests/step-by-step-journey.cypress.js @@ -3,6 +3,8 @@ import { deleteFile } from '../utils' const { waitForApplication, copyFile } = require('../utils') +const testDir = path.resolve(process.env.KIT_TEST_DIR || 'cypress/temp/test-project') + const fixtures = path.join(Cypress.config('fixturesFolder')) const fixtureViews = path.join(fixtures, 'views') @@ -29,20 +31,24 @@ const assertHidden = (step) => { cy.get(showHideLinkQuery(step)).should('contains.text', 'Show') } +const runScript = (script) => { + script = `cd ${testDir} && ${script}` + cy.task('log', script) + cy.exec(script) +} + describe('Step by step journey', async () => { - beforeEach(() => { - cy.exec('npm install jquery') - cy.wait(2000) + before(() => { + runScript('npm install jquery') waitForApplication() copyFile(stepByStepNavigationFixtureView, stepByStepNavigationView) cy.visit(stepByStepNavigationPath) cy.get('h1').should('contains.text', 'Juggling Tricks: step by step') }) - afterEach(() => { + after(() => { deleteFile(stepByStepNavigationView) - cy.exec('npm uninstall jquery') - cy.wait(2000) + runScript('npm uninstall jquery') }) it('renders ok', () => {