Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yosuke-furukawa/nock.jsx
https://github.com/yosuke-furukawa/nock.jsx
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/yosuke-furukawa/nock.jsx
- Owner: yosuke-furukawa
- Created: 2014-03-18T07:51:23.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T11:48:40.000Z (11 months ago)
- Last Synced: 2024-09-19T11:39:30.171Z (about 2 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Nock bindings for JSX
======================[Nock](https://github.com/pgte/nock) is a HTTP Mock module.
This nock.jsx is binding Nock for JSX.
Getting Started
======================For JSX user:
```javascript
import "nock.jsx/nock.jsx";
import "test-case.jsx";
import "nodejs.jsx/ext/needle.jsx";class _Test extends TestCase {
function testNockGet() :void {
this.async(function(async : AsyncContext) : void {
Nock.setUrl("http://www.google.com").get("/").reply(200, "Hello Google");
needle.get("http://www.google.com/", function(err, response, data){
this.expect(response.statusCode).toBe(200);
this.expect(data.toString()).toBe("Hello Google");
async.done();
});
}, 10000);
}
}
```For JavaScript user:
```javascript
var Nock = require('../nock.jsx').Nock;
var needle = require('needle');Nock.setUrl("http://www.google.com").get("/").reply(200, "Hello Google");
needle.get("http://www.google.com/", function(err, response, data){
console.log(data.toString()); // Hello Google
});
```