Skip to content

Commit

Permalink
delay jasmine and mocha execution
Browse files Browse the repository at this point in the history
  • Loading branch information
tarciosaraiva committed Jul 9, 2016
1 parent 2ac8590 commit 160df60
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
5 changes: 2 additions & 3 deletions karma/jasmine/client-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
beforeAll(function(done) {
client = example.createClient('http://localhost:1234')
projectsProvider = Pact({ consumer: 'Karma Jasmine', provider: 'Hello' })
setTimeout(function () {
done()
}, 2000)
// required for slower Travis CI environment
setTimeout(function () { done() }, 2000)
});

afterAll(function (done) {
Expand Down
36 changes: 17 additions & 19 deletions karma/mocha/client-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@

var client, projectsProvider;

// ugly but works... guess would be good to bring jasmine-beforeAll
beforeEach(function() {
before(function(done) {
client = example.createClient('http://localhost:1234');
projectsProvider = Pact({ consumer: 'Karma Mocha', provider: 'Hello' })
});
// required for slower Travis CI environment
setTimeout(function () { done() }, 1000)
})

after(function (done) {
projectsProvider.finalize()
.then(function () { done() }, function (err) { done(err) })
})

describe("sayHello", function () {
beforeEach(function (done) {
Expand All @@ -24,11 +30,8 @@
headers: { "Content-Type": "application/json" },
body: { reply: "Hello" }
}
}).then(function () { done() })
})

afterEach(function (done) {
projectsProvider.finalize().then(function () { done() })
})
.then(function () { done() }, function (err) { done(err) })
})

it("should say hello", function(done) {
Expand Down Expand Up @@ -69,13 +72,10 @@
}, { min: 1 })
}
}
}).then(function () { done() })
})
.then(function () { done() }, function (err) { done(err) })
})

afterEach(function (done) {
projectsProvider.finalize().then(function () { done() })
});

it("should return some friends", function(done) {
//Run the tests
client.findFriendsByAgeAndChildren('33', ['Mary Jane', 'James'])
Expand Down Expand Up @@ -106,13 +106,10 @@
headers: { "Content-Type": "application/json" },
body: { reply: "Bye" }
}
}).then(function () { done() })
})
.then(function () { done() }, function (err) { done(err) })
})

afterEach(function (done) {
projectsProvider.finalize().then(function () { done() })
});

it("should unfriend me", function(done) {
//Run the tests
client.unfriendMe()
Expand All @@ -139,7 +136,8 @@
willRespondWith: {
status: 404
}
}).then(function () { done() })
})
.then(function () { done() }, function (err) { done(err) })
})

it("returns an error message", function (done) {
Expand Down
6 changes: 4 additions & 2 deletions karma/mocha/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ module.exports = function (config) {
frameworks: ['mocha', 'chai', 'pact'],

// pact config
pact: {},
pact: {
port: 1234
},

// list of files / patterns to load in the browser
files: [
Expand Down Expand Up @@ -54,7 +56,7 @@ module.exports = function (config) {
customLaunchers: {
PhantomJS_without_security: {
base: 'PhantomJS',
flags: ['--web-security=false']
flags: ['--web-security=no']
}
},

Expand Down

0 comments on commit 160df60

Please sign in to comment.