karma-runner / karma

Spectacular Test Runner for JavaScript
http://karma-runner.github.io
MIT License
11.95k stars 1.71k forks source link

requirejs integration : cannot find 'handlebars' error when #245

Closed phtrivier closed 11 years ago

phtrivier commented 11 years ago

I'm trying to use the 'requirejs' integration, as described here :

What I did was :

curl http://registry.npmjs.org/testacular/-/testacular-0.5.6.tgz | tar -xvz && mv package testacular
// Sample Testacular configuration file, that contain pretty much all the available options
// It's used for running client tests on Travis (http://travis-ci.org/#!/vojtajina/testacular)
// Most of the options can be overriden by cli arguments (see testacular --help)
//
// For all available config options and default values, see:
// https://github.com/vojtajina/testacular/blob/stable/lib/config.js#L54

// base path, that will be used to resolve files and exclude
basePath = '.';

files = [
         MOCHA,
         MOCHA_ADAPTER,
         REQUIRE,
         REQUIRE_ADAPTER,

         // !! put all libs in requirejs 'paths' config here (included: false)
         {pattern: 'lib/**/*.js', included: false},

         // !! all src and test modules (included: false)
         {pattern: 'src/**/*', included: false},
         {pattern: 'test/**/*.test.js', included: false},

         // !! test main require module last
         'test/test-main.js'
       ];

// list of files to exclude
exclude = [
  // 'adapter/require.src.js'
];

// use dots reporter, as travis terminal does not support escaping sequences
// possible values: 'dots', 'progress', 'junit'
// CLI --reporters progress
reporters = ['dots', 'junit'];

junitReporter = {
  // will be resolved to basePath (in the same way as files/exclude patterns)
  outputFile: 'test-results.xml'
};

// web server port
// CLI --port 9876
port = 9876;

// cli runner port
// CLI --runner-port 9100
runnerPort = 9100;

// enable / disable colors in the output (reporters and logs)
// CLI --colors --no-colors
colors = true;

// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
// CLI --log-level debug
logLevel = LOG_INFO;

// enable / disable watching file and executing tests whenever any file changes
// CLI --auto-watch --no-auto-watch
autoWatch = true;

// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
// CLI --browsers Chrome,Firefox,Safari
browsers = ["Chrome"];

// If browser does not capture in given timeout [ms], kill it
// CLI --capture-timeout 5000
captureTimeout = 5000;

// Auto run tests on start (when browsers are captured) and exit
// CLI --single-run --no-single-run
singleRun = false;

// report which specs are slower than 500ms
// CLI --report-slower-than 500
reportSlowerThan = 500;

// compile coffee scripts
preprocessors = {
  '**/*.coffee': 'coffee'
};

I get an error, module 'handlebars' can not be found :

Cannot find module 'handlebars'
Error: Cannot find module 'handlebars'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (/home/phtrivier/prj/platform/apps/testacular/node_modules/istanbul/lib/report/html.js:7:18)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)

Error: Could not register report from file html.js
    at Factory.loadStandard (/home/phtrivier/prj/platform/apps/testacular/node_modules/istanbul/lib/util/factory.js:60:27)
    at Array.forEach (native)
    at Object.Factory.loadStandard (/home/phtrivier/prj/platform/apps/testacular/node_modules/istanbul/lib/util/factory.js:53:29)
    at Object.<anonymous> (/home/phtrivier/prj/platform/apps/testacular/node_modules/istanbul/lib/register-plugins.js:11:8)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)

I fear it could be an npm issue, but I'm not very confortable with nodejs yet, so I'm not sure which direction I have to look into...

Any help welcome.

Thanks.

phtrivier commented 11 years ago

Might be related, but now it's even worse ...

I get this :

phtrivier@murphy:~/prj/platform/workspace_git/testacular/test/e2e/requirejs$ testacular start

module.js:340
    throw err;
          ^
Error: Cannot find module 'optimist'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (/home/phtrivier/prj/platform/apps/testacular/lib/cli.js:2:16)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)

I have no idea what to make of this... could this be a dependency issue in testacular package description ? Or is it definitely a problem in my local installation ?

dignifiedquire commented 11 years ago
  1. For the first attempt try npm install without the global flag.
  2. Can you post the result of npm list for both variants?
phtrivier commented 11 years ago

Hi

It seems like I can't install it without the g flag :

phtrivier@murphy:~/prj/platform/workspace_git/testacular/test/e2e/requirejs$ npm install testacular@canary
npm http GET https://registry.npmjs.org/testacular
npm http 200 https://registry.npmjs.org/testacular
npm http GET https://registry.npmjs.org/testacular/-/testacular-0.5.6.tgz
npm http 200 https://registry.npmjs.org/testacular/-/testacular-0.5.6.tgz
npm WARN prefer global testacular@0.5.6 should be installed with -g

After installing with -g, I get this list :

testacular@0.5.6 /home/phtrivier/prj/platform/workspace_git/testacular
├── chokidar@0.5.0
├── coffee-script@1.4.0
├── colors@0.6.0-1
├── dateformat@1.0.3-1.2.3
├─┬ glob@3.1.14
│ ├── graceful-fs@1.1.14
│ └── inherits@1.0.0
├── growly@1.0.0
├─┬ grunt@0.4.0rc3
│ ├── async@0.1.22
│ ├── coffee-script@1.3.3
│ ├── dateformat@1.0.2-1.2.3
│ ├── eventemitter2@0.4.11
│ ├── findup-sync@0.1.1
│ ├── hooker@0.2.3
│ ├── iconv-lite@0.2.7
│ ├─┬ js-yaml@1.0.3
│ │ └─┬ argparse@0.1.8
│ │   ├── underscore@1.3.3
│ │   └── underscore.string@2.1.1
│ ├─┬ nopt@1.0.10
│ │ └── abbrev@1.0.3
│ └── underscore.string@2.2.0rc
├─┬ grunt-contrib-jshint@0.1.0
│ └─┬ jshint@0.9.1
│   ├── cli@0.4.3
│   └─┬ minimatch@0.0.5
│     └── lru-cache@1.0.6
├─┬ grunt-jasmine-node@0.0.4
│ └─┬ jasmine-node@1.0.28
│   ├── jasmine-reporters@0.2.1
│   ├── requirejs@2.1.2
│   ├── underscore@1.4.3
│   └── walkdir@0.0.5
├─┬ http-proxy@0.8.5
│ └── pkginfo@0.2.3
├─┬ istanbul@0.1.22
│ ├── abbrev@1.0.3
│ ├── async@0.1.22
│ ├─┬ escodegen@0.0.15
│ │ ├── esprima@1.0.2
│ │ └─┬ source-map@0.1.8
│ │   └── amdefine@0.0.4
│ ├── esprima@0.9.9
│ ├─┬ fileset@0.1.3
│ │ ├─┬ glob@3.0.1
│ │ │ ├── fast-list@1.0.2
│ │ │ ├── graceful-fs@1.1.14
│ │ │ └── inherits@1.0.0
│ │ └─┬ minimatch@0.1.5
│ │   └── lru-cache@1.0.6
│ ├─┬ handlebars@1.0.7
│ │ └── uglify-js@1.2.6
│ ├── mkdirp@0.3.4
│ ├── nopt@2.0.0
│ └── wordwrap@0.0.2
├─┬ LiveScript@1.1.0
│ └── prelude-ls@0.6.0
├── lodash@0.9.2
├─┬ minimatch@0.2.9
│ ├── lru-cache@2.0.4
│ └── sigmund@1.0.0
├── mocks@0.0.10
├─┬ optimist@0.3.5
│ └── wordwrap@0.0.2
├── pause@0.0.1
├── q@0.8.11
├─┬ rimraf@2.0.3
│ └── graceful-fs@1.1.14
├─┬ socket.io@0.9.13
│ ├── base64id@0.1.0
│ ├── policyfile@0.0.4
│ ├── redis@0.7.3
│ └─┬ socket.io-client@0.9.11
│   ├─┬ active-x-obfuscator@0.0.1
│   │ └── zeparser@0.0.5
│   ├── uglify-js@1.2.5
│   ├─┬ ws@0.4.24
│   │ ├── commander@0.6.1
│   │ ├── options@0.0.3
│   │ └── tinycolor@0.0.1
│   └── xmlhttprequest@1.4.2
├── testacular@0.5.6 extraneous
├── which@1.0.5
└── xmlbuilder@0.4.2

npm ERR! extraneous: testacular@0.5.6 /home/phtrivier/prj/platform/workspace_git/testacular/node_modules/testacular
npm ERR! not ok code 0

So I get a version of optimist and handlebars, but testacular is marked as "extraneous"...

vojtajina commented 11 years ago

You can just remove it, that's because you install it locally first (npm gives warning that Testacular should be installed with -g, but that does not affect the local installation), so: rm -rf .../testacular/node_modules/testacular

vojtajina commented 11 years ago

For integration with requirejs, use this first https://github.com/vojtajina/testacular/tree/master/test/e2e/requirejs Be sure to check out the docs as well https://github.com/vojtajina/testacular/wiki/RequireJS

vojtajina commented 11 years ago

Feel free to re-open if you still think there is an issue.