Skip to content

Commit 31aed42

Browse files
committed
Replace jsonapi-mock with fake-json-api-server.
1 parent e80cd74 commit 31aed42

File tree

8 files changed

+150
-642
lines changed

8 files changed

+150
-642
lines changed

examples/fake-json-api-server.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// server.js
2+
var FakeServer = require('fake-json-api-server/src/nodeServer');
3+
4+
var resources = require('./testapp.json')
5+
6+
new FakeServer({
7+
port: 3000,
8+
resources: resources
9+
});

examples/testapp/src/components/JsonapiVuex.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<input :id='"input_" + name' v-model="widget[name]"/>
2828
</div>
2929
<div>
30-
<button @click="patchRecord(widget)">Submit</button>
30+
<button name="patch_button" @click="patchRecord(widget)">Patch</button>
3131
</div>
3232
</div>
3333
</div>

examples/testapp/src/store.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Vue.use(Vuex)
88

99
const api = axios.create({
1010
// connect to local jsonapi-mock server
11-
baseURL: 'http://localhost:3004',
11+
baseURL: 'http://localhost:3000',
1212
headers: {
1313
'Content-Type': 'application/vnd.api+json',
1414
'Accept': 'application/vnd.api+json'

nightwatch.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ module.exports = {
66
}
77
},
88
"test_settings": {
9+
"Firefox": {
10+
"desiredCapabilities": {
11+
"browserName": "firefox",
12+
"acceptInsecureCerts": true,
13+
}
14+
},
915
"FirefoxHeadless": {
1016
"desiredCapabilities": {
1117
"browserName": "firefox",

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"eslint": "^5.6.1",
1919
"eslint-loader": "^2.1.1",
2020
"eslint-plugin-vue": "^4.7.1",
21+
"fake-json-api-server": "^1.6.0",
2122
"geckodriver": "^1.14.1",
22-
"jsonapi-mock": "^1.4.41",
2323
"karma": "^3.0.0",
2424
"karma-chai": "^0.1.0",
2525
"karma-coverage": "^1.1.2",
@@ -62,11 +62,11 @@
6262
"url": "https://github.com/mrichar1/jsonapi-vuex/issues"
6363
},
6464
"scripts": {
65-
"test": "npm run unit -- --single-run",
65+
"test": "npm run unit -- --single-run && npm run e2e",
6666
"unit": "karma start",
67-
"e2e": "concurrently --success first --kill-others \"npm:jsonapimock\" \"vue-cli-service test:e2e --env FirefoxHeadless\"",
68-
"testapp": "concurrently --kill-others \"npm:jsonapimock\" \"vue-cli-service serve\"",
69-
"jsonapimock": "cp examples/testapp/testapp.json examples/testapp/tmp.json && jsonapi-mock"
67+
"e2e": "concurrently --success first --kill-others \"npm:fakeapiserver\" \"vue-cli-service test:e2e --env FirefoxHeadless\"",
68+
"testapp": "concurrently --kill-others \"npm:fakeapiserver\" \"vue-cli-service serve\"",
69+
"fakeapiserver": "node examples/fake-json-api-server.js"
7070
},
7171
"dependencies": {
7272
"jsonpath": "^1.0.0",

tests/e2e/specs/test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ module.exports = {
3939
browser.clearValue('#input_color')
4040
browser.setValue('#input_color', 'red')
4141

42+
// Move so that element is in view (Firefox doesn't render items off-screen)
43+
browser.getLocationInView('button[name=patch_button]')
44+
browser.click('button[name=patch_button]')
45+
// Pause for API response
46+
browser.pause(1000)
47+
4248
// Check changes propagate
4349
be.element('#span_name').text.to.equal('cog')
4450
be.element('#span_color').text.to.equal('red')

0 commit comments

Comments
 (0)