lundi 13 mars 2017

Chai Assertions Http Request

I am trying to learn javascript. I am attempting to write a few assertions against a public echo server (http://ift.tt/2mDmbgt) however I am failing (one thing after another). I am not sure I am doing this in the best way. Someone please help me. Current error: Error: Script error. (:0) i have even gone as far as to upload chai-http.js just to get a mirror for it.

also here it is live with JS fiddle: http://ift.tt/2mTP0HH

seems this line is broken:

chai.assert(res).to.have.status(200);

<html>
<head>
    <title>So angry...</title>

    <!-- Styling -->
    <link rel="stylesheet" href="http://ift.tt/2mDw2Ty"/>

    <!-- JS -->
    <script src="http://ift.tt/2mTLYmx"></script>
    <script src="http://ift.tt/2mDlHqp"></script>
    <script src="http://ift.tt/2mTL4GE"></script>
</head>
<body>


    <div id="mocha"></div>

<script>
    mocha.setup('bdd');
    chai.use(chaiHttp);

    describe('Testing Stuff', function () {

        // Just testing this
        it('Basic HTTP Request', function(done) {
            chai.request('https://jsfiddle.net')
            .post('/echo/html/')
            .end(function(err, res) {
                chai.expect(res).to.have.status(200);
                done();
            });
        });

    });

    mocha.run();
</script>
</body>

Aucun commentaire:

Enregistrer un commentaire