SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Make returning different messages

    When I run 'make' on the code in Chapter 3 (Introduction), I don't see the messages shown on page 24, i.e.
    3 of 3 tests failed:
    1) exchange buy should add a BUY nockmarket order:
    ReferenceError: exchange is not defined
    Instead, I see the following messages:-
    ...
    ✖ 3 of 3 tests failed:
    Makefile:2: recipe for target `test' failed
    make: *** [test] Error 3
    I'm using the files from the code download and 'make' is run via Cygwin.

    Is there something wrong with my setup?

  2. #2
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Can you paste the contents of your exchange.test.js file in to a [ code] block - let's first rule out any errors in that file
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  3. #3
    SitePoint Author
    Join Date
    Nov 2012
    Posts
    48
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    THead, Cygwin is not the easiest thing to deal with. Although not idiomatic you can try running mocha directly:

    Code:
    C:\NODEJS1\chapter02>.\node_modules\.bin\mocha -u tdd
    What happens when you try the above? If that still fails as per AussieJohn's suggestion, if you post the contents of your exchange.test.js file we can check it for correctness.

  4. #4
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Don Nguyen View Post
    THead, Cygwin is not the easiest thing to deal with. Although not idiomatic you can try running mocha directly:

    Code:
    C:\NODEJS1\chapter02>.\node_modules\.bin\mocha -u tdd
    NB: If you install mocha globally
    Code:
    C:\> npm install mocha -g
    You can then simply call mocha without the path prefix
    Code:
    C:\NODEJS1\chapter02> mocha -u tdd
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  5. #5
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Output from that command

    Quote Originally Posted by Don Nguyen View Post
    THead, Cygwin is not the easiest thing to deal with. Although not idiomatic you can try running mocha directly:

    Code:
    C:\NODEJS1\chapter02>.\node_modules\.bin\mocha -u tdd
    What happens when you try the above? If that still fails as per AussieJohn's suggestion, if you post the contents of your exchange.test.js file we can check it for correctness.
    Here's the output from that command. They appear to be the same errors as shown in the book, but a lot more verbose.
    (BTW, I've had to leave off the last few lines of the 3rd error as including them appears to blow up the forum software. Those lines are identical to those appearing in the other errors, however.)
    Code:
    C:\Data\Work\nodeJS\apps\nockmarket>.\node_modules\.bin\mocha -u tdd
    
      ...
    
      ? 3 of 3 tests failed:
    
      1) exchange buy should add a BUY nockmarket order:
         ReferenceError: exchange is not defined
          at Context.<anonymous> (C:\Data\Work\nodeJS\apps\nockmarket\test\exchange.test.js:10:20)
          at Test.Runnable.run (C:\Data\Work\nodeJS\apps\nockmarket\node_modules\mocha\lib\runnable.js:171:15)
          at Runner.runTest (C:\Data\Work\nodeJS\apps\nockmarket\node_modules\mocha\lib\runner.js:300:10)
          at Runner.runTests.next (C:\Data\Work\nodeJS\apps\nockmarket\node_modules\mocha\lib\runner.js:346:12)
          at next (C:\Data\Work\nodeJS\apps\nockmarket\node_modules\mocha\lib\runner.js:228:14)
          at Runner.hooks (C:\Data\Work\nodeJS\apps\nockmarket\node_modules\mocha\lib\runner.js:237:7)
          at next (C:\Data\Work\nodeJS\apps\nockmarket\node_modules\mocha\lib\runner.js:185:23)
          at Runner.hook (C:\Data\Work\nodeJS\apps\nockmarket\node_modules\mocha\lib\runner.js:205:5)
          at process.startup.processNextTick.process._tickCallback (node.js:244:9)
    
      2) exchange sell should add a SELL nockmarket order:
         ReferenceError: exchange is not defined
          at Context.<anonymous> (C:\Data\Work\nodeJS\apps\nockmarket\test\exchange.test.js:16:20)
          at Test.Runnable.run (C:\Data\Work\nodeJS\apps\nockmarket\node_modules\mocha\lib\runnable.js:171:15)
          at Runner.runTest (C:\Data\Work\nodeJS\apps\nockmarket\node_modules\mocha\lib\runner.js:300:10)
          at Runner.runTests.next (C:\Data\Work\nodeJS\apps\nockmarket\node_modules\mocha\lib\runner.js:346:12)
          at next (C:\Data\Work\nodeJS\apps\nockmarket\node_modules\mocha\lib\runner.js:228:14)
          at Runner.hooks (C:\Data\Work\nodeJS\apps\nockmarket\node_modules\mocha\lib\runner.js:237:7)
          at next (C:\Data\Work\nodeJS\apps\nockmarket\node_modules\mocha\lib\runner.js:185:23)
          at Runner.hook (C:\Data\Work\nodeJS\apps\nockmarket\node_modules\mocha\lib\runner.js:205:5)
          at process.startup.processNextTick.process._tickCallback (node.js:244:9)
    
      3) exchange sell should produce trades:
         ReferenceError: exchange is not defined
          at Context.<anonymous> (C:\Data\Work\nodeJS\apps\nockmarket\test\exchange.test.js:22:20)
          at Test.Runnable.run (C:\Data\Work\nodeJS\apps\nockmarket\node_modules\mocha\lib\runnable.js:171:15)
          at Runner.runTest (C:\Data\Work\nodeJS\apps\nockmarket\node_modules\mocha\lib\runner.js:300:10)
          at Runner.runTests.next (C:\Data\Work\nodeJS\apps\nockmarket\node_modules\mocha\lib\runner.js:346:12)
          ...
          ...

  6. #6
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here you go ...

    Code:
    'use strict';
    
    
    var assert = require('assert')
      , should = require('should');
    
    
    var exchangeData = {};
    
    
    suite('exchange', function() {
      test('buy should add a BUY nockmarket order', function(done) {
        exchangeData = exchange.buy(40, 100, exchangeData);
        exchangeData.buys.volumes[40].should.eql(100);
        done();
      });
      
      test('sell should add a SELL nockmarket order', function(done) {
        exchangeData = exchange.sell(41, 200, exchangeData);
        exchangeData.sells.volumes['41'].should.eql(200);
        done();
      });
      
      test('sell should produce trades', function(done) {
        exchangeData = exchange.sell(40, 75, exchangeData);
        exchangeData.trades[0].price.should.eql(40);
        exchangeData.trades[0].volume.should.eql(75);
        exchangeData.buys.volumes[40].should.eql(25);
        exchangeData.sells.volumes[41].should.eql(200);
        done();
      });
    });

  7. #7
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    I think what might be happening here is that the exchange.js from the lib folder is not being included.

    Try adding it to the list of requires at the top and see how you go:

    Code:
    var assert = require('assert')
      , should = require('should')
      , exchange = require('../lib/exchange');
    
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  8. #8
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AussieJohn View Post
    I think what might be happening here is that the exchange.js from the lib folder is not being included.

    Try adding it to the list of requires at the top and see how you go:

    Code:
    var assert = require('assert')
      , should = require('should')
      , exchange = require('../lib/exchange');
    
    I haven't got that far. As of page 24, we haven't created that folder. The tests have been written but not the code that they are testing.

  9. #9
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by THead View Post
    I haven't got that far. As of page 24, we haven't created that folder. The tests have been written but not the code that they are testing.
    Ah well, in that case we're on the right track. If your tests are failing, then you're ready to move on to the next steps (which is writing the code that they test).

    As Don mentioned, Cygwin can be a little troublesome, but if you install the Mocha module globally (npm install mocha -g) you should be able to run the tests in regular Windows command prompt by using mocha -u tdd

    P.S. Thanks for that tip @Don Nguyen ;, I hadn't actually used Mocha before, this is a good chance to get familiar with it
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  10. #10
    SitePoint Author
    Join Date
    Nov 2012
    Posts
    48
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    THead, although slightly counterintuitive the failure that you have posted is OK. From the snippet that you have posted it looks like Mocha is working which is the important thing. If the tests are still failing at the end of the chapter THEN we have a problem :-)

    @AussieJohn one of many good frameworks available. Hope you are enjoying the book let me know if you have any questions.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •