-
Notifications
You must be signed in to change notification settings - Fork 724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFR] Use fakerest and webpack-dev-server instead of json-server and grunt-connect #625
Changes from all commits
1004157
138e018
ece2365
c4d1700
8ce1a16
f447437
d437e9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ install: | |
./node_modules/protractor/bin/webdriver-manager update | ||
|
||
run: | ||
@./node_modules/.bin/grunt | ||
@./node_modules/webpack-dev-server/bin/webpack-dev-server.js --colors --devtool cheap-module-inline-source-map --content-base examples/blog --port 8000 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't forget to remove the related conf in Gruntfile There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
build: | ||
@NODE_ENV=production ./node_modules/webpack/bin/webpack.js -p --optimize-minimize --optimize-occurence-order --optimize-dedupe --progress --devtool source-map | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../node_modules/fakerest/dist/FakeRest.min.js | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand what that file does? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's just a symlink to the fakerest node module, to be able to import it in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah OK, that's how GitHub show symlinks, I didn't know |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../node_modules/sinon/pkg/sinon-server-1.14.1.js |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
// setup fake server | ||
var restServer = new FakeRest.Server('http://localhost:3000'); | ||
var testEnv = window.location.pathname.indexOf('test.html') !== -1; | ||
restServer.init(apiData); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. apiData is global? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nevermind, I saw what you loaded the data in a |
||
restServer.toggleLogging(); // logging is off by default, enable it | ||
|
||
// use sinon.js to monkey-patch XmlHttpRequest | ||
sinon.FakeXMLHttpRequest.useFilters = true; | ||
sinon.FakeXMLHttpRequest.addFilter(function (method, url) { | ||
// Do not catch webpack sync, config.js transformation but catch /upload in test env | ||
return url.indexOf('/socket.io/') !== -1 || url.indexOf('config.js') !== -1 | ||
|| (!testEnv && url.indexOf('/upload') !== -1); | ||
}); | ||
|
||
var server = sinon.fakeServer.create(); | ||
server.autoRespond = true; | ||
server.autoRespondAfter = 0; // answer immediately | ||
|
||
server.respondWith(restServer.getHandler()); | ||
|
||
if (testEnv) { | ||
server.respondWith(function (response) { | ||
if (response.url.indexOf('/upload') !== -1) { | ||
response.respond(JSON.stringify({apifilename: 'my-cat.jpg'})); | ||
} | ||
}); | ||
} | ||
}()); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ describe('List filter', function () { | |
var hasToLoad = true; | ||
beforeEach(function() { | ||
if (hasToLoad) { | ||
browser.get(browser.baseUrl + '#/comments/list'); | ||
browser.get(browser.baseUrl + '#/comments/list'); | ||
} | ||
hasToLoad = true; | ||
}); | ||
|
@@ -22,7 +22,7 @@ describe('List filter', function () { | |
return $$('ma-view-actions button').then(function(buttons) { | ||
expect(buttons[0].getText()).toBe(' Add filter'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('filter button', function() { | ||
|
@@ -94,7 +94,7 @@ describe('List filter', function () { | |
return browser.driver.sleep(600); // debounce delay | ||
}) | ||
.then(function() { | ||
return $$('.grid tr td:nth-child(4)'); | ||
return $$('.grid tr td:nth-child(4)'); | ||
}) | ||
.then(function (tdElements) { | ||
expect(tdElements.length).toBe(1); | ||
|
@@ -116,7 +116,7 @@ describe('List filter', function () { | |
return browser.driver.sleep(600); // debounce delay | ||
}) | ||
.then(function() { | ||
return $$('.grid tr td:nth-child(4)'); | ||
return $$('.grid tr td:nth-child(4)'); | ||
}) | ||
.then(function (tdElements) { | ||
expect(tdElements.length).toBe(10); | ||
|
@@ -184,7 +184,7 @@ describe('List filter', function () { | |
return $$('ma-datagrid-pagination .total'); | ||
}) | ||
.then(function (totalElements) { | ||
expect(totalElements[0].getText()).toBe('1 - 5 on 5'); | ||
expect(totalElements[0].getText()).toBe('1 - 4 on 4'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does it change if the dataset is the same? Something's wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know how it's possible to find 5 records, see http://ng-admin.marmelab.com/#/comments/list?search={%22q%22:%22be%22}&page=1 But if I search for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, FakeRest doesn't handle the q search inside composite fields (the 5th comment has an author.name containing 'be'. |
||
}); | ||
}); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need to copy if there is a symlink?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because copy from example build directory to test build directory does not copy symlinks (which would be broken anyway).