driver: ensure fixture cache is cleared between test runs

This commit is contained in:
Chris Breiding
2017-06-16 17:00:18 -04:00
parent a365deb830
commit 0a75d9c94a
2 changed files with 7 additions and 15 deletions
@@ -4,23 +4,19 @@ Promise = require("bluebird")
$Cy = require("../../cypress/cy")
utils = require("../../cypress/utils")
cache = {}
fixturesRe = /^(fx:|fixture:)/
clone = (obj) ->
JSON.parse(JSON.stringify(obj))
module.exports = (Cypress, Commands) ->
## this is called at the beginning of run, so clear the cache
cache = {}
fixture = (fixture, options) =>
new Promise (resolve) ->
Cypress.trigger("fixture", fixture, options, resolve)
## reset the cache whenever we
## completely stop
Cypress.on "stop", ->
cache = {}
Commands.addAll({
fixture: (fx, args...) ->
## if we already have cached
@@ -43,8 +43,7 @@ describe "$Cypress.Cy Fixtures Commands", ->
expect(obj).to.deep.eq {foo: "bar"}
describe "cancellation", ->
## FIXME: fails when running all tests in this file
it.skip "cancels promise", (done) ->
it "cancels promise", (done) ->
## respond after 50 ms
@respondWith({}, 50)
@@ -83,8 +82,7 @@ describe "$Cypress.Cy Fixtures Commands", ->
@cy.fixture("err")
## FIXME
it.skip "throws after timing out", (done) ->
it "throws after timing out", (done) ->
@respondWith({foo: "bar"}, 1000)
logs = []
@@ -103,8 +101,7 @@ describe "$Cypress.Cy Fixtures Commands", ->
@cy.fixture("foo", {timeout: 50})
## FIXME: these are failing because the fixture cache needs to be cleared somehow
describe.skip "timeout", ->
describe "timeout", ->
it "sets timeout to Cypress.config(responseTimeout)", ->
@Cypress.config("responseTimeout", 2500)
@@ -140,8 +137,7 @@ describe "$Cypress.Cy Fixtures Commands", ->
## restores the timeout afterwards
expect(@cy._timeout()).to.eq(100)
## FIXME: these are failing because the fixture cache needs to be cleared somehow
describe.skip "caching", ->
describe "caching", ->
it "caches fixtures by name", ->
@respondWith({foo: "bar"})
cy.fixture("foo").then (obj) =>