Comments (4)
Maybe you don't have permission to listen on that port? What is the code you're testing?
from api-easy.
It's a node.js server that's working fine (I'm actually testing it with Objective-C and Chrome's Dev HTTP Client utility. I'm running on port 8080 without issues:
9 Jul 00:09:02 - [nodemon] starting `node app.js localhost 8080`
Express HTTP server listening on port 8080
Assuming that the server is running fine, the above code would report a 403 as opposed to permission denied, right? Or is this permission denied the result of an HTTP 403? (which the server returns if no authentication has succeeded)
Thank you.
from api-easy.
I'm having no trouble at all performing the invocation from the browser. Weird...
from api-easy.
OK, somehow I got it to work (I've tried so many things I'm not sure what made it work.) This is the dummy test I setup in place:
function showStats(req, res) {
log.info('GET /admin/stats');
var someValue = '12345';
res.writeHead(200, {
'Content-Type': 'application/json',
});
res.write(JSON.stringify({
someValue: someValue
}));
return res.end();
}
module.exports.initialize = function (app) {
app.get('/admin/stats', showStats);
};
This is the test:
var APIeasy = require('api-easy'),
assert = require('assert');
var suite = APIeasy.describe('your/awesome/api');
suite.discuss('When using your awesome API')
.discuss('and your awesome resource')
.use('localhost', 8080)
.setHeader('Content-Type', 'application/json')
.get('/admin/stats')
.expect(200)
.export(module);
When I call npm test, I get the following:
Macintosh:fooTest tito$ npm test
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No readme data.
> [email protected] test /Users/tito/Desktop/fooTest
> vows test/*-test.js
✗
When using your awesome API and your awesome resource A GET to /admin/stats
✗ should respond with 200
» expected 200,
got 400 (==) // api-easy.js:290
✗ Broken » 1 broken (1.330s)
npm ERR! weird error 1
npm ERR! not ok code 0
Macintosh:fooTest tito$
How in the world is it getting a 400? It's impossible! Again, if I invoke it via http://localhost:8080/admin/stats I get back:
{
"someValue":"12345"
}
Even Charles proxy shows that the response is a 200. What gives?
from api-easy.
Related Issues (20)
- Recursive calls Examples HOT 8
- "Content-Type" header with GET request HOT 2
- Please update vows version
- How to use the same tests in different environments (dev, beta, staging etc.)
- offtopic: why do you parse params like this HOT 2
- API-easy not compatible with latest versions of node? HOT 3
- Unable to stall tests until connections are made HOT 3
- Cannot post a body that is not an object HOT 3
- Unable to pass data (and update POST data) between chained APIEasy calls. HOT 3
- api-easy usage with Express (node lib) HOT 2
- .put() does not work as expected HOT 1
- i get error ECONNREFUSED. HOT 1
- No way to tests API over SSL HOT 2
- Question: using for a smoke test
- Asynchonous error HOT 1
- How do I test multipart requests with apieasy?
- afters
- Broken doc page HOT 1
- Test Execution Reports
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from api-easy.