1

I know there are a couple of similar questions already answered (Testing custom JavaScript (not Node module) with Intern and Can't get Intern to run Node.js Module), but even after reading those answers, I've still been unable to get some simple tests to run using Intern. I feel like there is just one small piece that I am overlooking or missing.

I am trying to evaluate Intern for use with an existing Javascript project. It's not a Node project, just plain Javascript. If it matters, I am trying to perform this evaluation on a Windows machine.

  1. My project hierarchy looks like this:

    APEFIntern/
        apeform/
            test/
                intern.js      - Intern configuration
                spec_inwf.js   - Tests for inwf
            inwf.js            - Code to test
        intern/
    
  2. Intern configuration file:

    // ...
    
    // Configuration options for the module loader; any AMD configuration options supported by the Dojo loader can be
    // used here
    loader: {
        // Packages that should be registered with the loader in each testing environment
        //packages: [ 'apeform' ]
    },
    
    // Non-functional test suite(s) to run in each browser
    suites: [ 'apeform/test/spec_inwf' ],
    
    // ...
    

    I'm pretty new to Node and AMD, but I believe that since my project is not a node project, I do not need to use the loader.packages configuration?

  3. Test file spec_inwf.js

    define([
    'intern!bdd',
    'intern!chai!expect',
    'apeform/inwf.js'
    ], function (bdd, expect) {
        with (bdd) {
            describe("inwf suite", function () {
                // Tests
            });
        }
    });
    
  4. I execute the following command to try and run the tests:

    node client.js config=apeform/test/intern
    

    The only output I receive from the command is:

    Defaulting to "console" reporter
    

If I set the suites array to be empty in the Intern configuration, I get the message "0/0 tests passed" when I execute the command in #4. I believe this is the correct output. But whenever I try to connect to a test suite, the tests aren't run. I'm not sure what else I'm missing from this equation. Any help would be appreciated.

Community
  • 1
  • 1
cprokopiak
  • 73
  • 4

1 Answers1

0

It looks like you have a small syntax issue in your spec_inwf.js test file:

'intern!chai!expect',

should be

'intern/chai!expect',

Everything else looks fine with your setup.

Note: your statement about not needing to use the loader.packages config if your project isn't a Node project is not really accurate. You don't need to use it in this particular case with the file structure you provided, however. The amdjs packages documentation may be worth a read for a better understanding of this configuration option, as it is AMD-specific, not Intern specific. Hope this helps.

bitpshr
  • 1,033
  • 2
  • 9
  • 21
  • 1
    Thank you very much. I don't know how many times I must have overlooked that issue. I will take a look at the link you provided. Intern is really starting to look like an incredible tool. – cprokopiak May 21 '13 at 02:00
  • Is the above answer accurate for Intern 1.1? It appears that it is not in light of https://github.com/theintern/intern/wiki/Changelog#since-10 where the intern dir is placed under node_modules dir not as a sibling of the project. Please describe a proper location of test files, config file, modules being tested and the web root. – teaman Jun 25 '13 at 22:50