diff --git a/cypress/e2e/api/SessionApi.spec.js b/cypress/e2e/api/SessionApi.spec.js index c459dc72f3f..5e6363644b3 100644 --- a/cypress/e2e/api/SessionApi.spec.js +++ b/cypress/e2e/api/SessionApi.spec.js @@ -41,35 +41,28 @@ describe('The session Api', function() { }) describe('open the session', function() { - let fileId - let filePath - beforeEach(function() { - cy.uploadTestFile('test.md') - .then(id => { - fileId = id - }) - cy.testName().then(name => { - filePath = `/${name}.md` - }) + cy.uploadTestFile('test.md').as('fileId') + cy.testName().then(name => `/${name}.md`).as('filePath') }) it('returns connection', function() { - cy.createTextSession(fileId).then(connection => { + cy.createTextSession(this.fileId).then(connection => { cy.wrap(connection) .its('document.id') - .should('equal', fileId) + .should('equal', this.fileId) connection.close() }) }) it('provides initial content', function() { - cy.createTextSession(fileId, { filePath }).then(connection => { - cy.wrap(connection) - .its('state.documentSource') - .should('eql', '## Hello world\n') - connection.close() - }) + cy.createTextSession(this.fileId, { filePath: this.filePath }) + .then(connection => { + cy.wrap(connection) + .its('state.documentSource') + .should('eql', '## Hello world\n') + connection.close() + }) }) it('handles invalid file id', function() {