Code Monkey home page Code Monkey logo

Comments (20)

vidartf avatar vidartf commented on June 4, 2024 1

Works locally with latest fix, and Appveyor now matches Travis. 👍

from karma-typescript.

vidartf avatar vidartf commented on June 4, 2024

Config file:

module.exports = function (config) {
  config.set({
    basePath: '..',
    frameworks: ['mocha', 'karma-typescript'],
    files: [
      { pattern: "test/src/**/*.ts" }
    ],
    port: 9876,
    colors: true,
    singleRun: true,
    logLevel: config.LOG_INFO,

    preprocessors: {
      '**/*.ts': ['karma-typescript']
    },

    reporters: ['mocha', 'karma-typescript'],

    karmaTypescriptConfig: {
      tsconfig: 'test/src/tsconfig.json'
    }
  });
};

from karma-typescript.

vidartf avatar vidartf commented on June 4, 2024

Progress report 1:
I have had the @types/* packages installed all the time, but name resolution was fixed by adding the following lines to typings.d.ts:

/// <reference types="mocha"/>
/// <reference types="expect.js"/>
/// <reference types="node"/>

Now the issue is:

> karma start --browsers=Chrome test/karma.conf.js

23 11 2016 13:56:33.064:INFO [compiler.karma-typescript]: Compiling project using Typescript 2.0.10

START:
23 11 2016 13:56:36.334:INFO [compiler.karma-typescript]: Compiled 15 files in 2712 ms.
23 11 2016 13:56:37.260:INFO [builtin-bundler.karma-typescript]: Bundled imports for 15 file(s) in 421 ms.
23 11 2016 13:56:37.330:INFO [karma]: Karma v1.3.0 server started at http://localhost:9876/
23 11 2016 13:56:37.330:INFO [launcher]: Launching browser Chrome with unlimited concurrency
23 11 2016 13:56:37.336:INFO [launcher]: Starting browser Chrome
23 11 2016 13:56:38.680:INFO [Chrome 54.0.2840 (Windows 10 0.0.0)]: Connected on socket /#xrQqAxx3J2WsanHOAAAA with id 38721184
Chrome 54.0.2840 (Windows 10 0.0.0) ERROR
  Uncaught Error: Could not find module

  'expect.js' from

  'C:/dev/nbdime/nbdime-web/test/src/common/collapsiblepanel.spec.js' using paths

  [expect.js]
  [.../test/src/common/expect.js]
  [.../test/src/common/expect.js.js]

  at node_modules/karma-typescript/lib/bundlers/builtin/commonjs.js:46

Finished in 0.188 secs / 0 secs

SUMMARY:
√ 0 tests completed

from karma-typescript.

vidartf avatar vidartf commented on June 4, 2024

Note that the previous error still appears with the following in the karma config:

    files: [
      { pattern: "node_modules/expect.js/index.js" },
      { pattern: "test/src/**/*.ts" }
    ],

from karma-typescript.

vidartf avatar vidartf commented on June 4, 2024

Note that the code line in question reads:

import expect = require('expect.js');

Is it maybe that import name = require("name"); is not supported?

from karma-typescript.

vidartf avatar vidartf commented on June 4, 2024

Or is it maybe the expect.js -> expect.js/index.js that throws it off?

from karma-typescript.

monounity avatar monounity commented on June 4, 2024

Hey @vidartf! I've added an example project for Mocha now, if you want to try it out use the latest from master: npm install https://github.com/monounity/karma-typescript.

from karma-typescript.

vidartf avatar vidartf commented on June 4, 2024

Thanks! Master seem to have fixed the issue. I would note that normal tsc compilation works without manually specifying the declarations in typings.d.ts (it searches @types for declarations), but I'm ok with this workaround for now.

from karma-typescript.

monounity avatar monounity commented on June 4, 2024

Great!
Your project should run in karma-typescript without the types section in your tsconfig, I include types only because Atom can't find the typings automatically...

from karma-typescript.

vidartf avatar vidartf commented on June 4, 2024

Well, without the types specification, I get the errors as included in the original post.

from karma-typescript.

monounity avatar monounity commented on June 4, 2024

That's weird, I can run the mocha example project with and without the types bit on my end. What version of Typescript are you using? Doesn't the example project work without typesfor you?

from karma-typescript.

vidartf avatar vidartf commented on June 4, 2024

Feel free to try out this setup:
https://github.com/vidartf/karma-ts-test/

from karma-typescript.

monounity avatar monounity commented on June 4, 2024

Your example project runs without any error messages on my end, the compiler picks up node_modules/@types/expect.js/index.d.tsand node_modules/@types/mocha/index.d.ts... The test that should fail, as intended, fails with expected 13 to equal 42.

My environment:

OS X 10.11.6
Node.js 6.40
Karma 1.3.0
Typescript 2.0.10

from karma-typescript.

vidartf avatar vidartf commented on June 4, 2024

Hmm. Running the test project in another environment than previously allows the tests to run as they should, but still errors during compilation:

ERROR [compiler.karma-typescript]: test/src/sub/code.spec.ts(9,1): error TS2304: Cannot find name 'describe'.
ERROR [compiler.karma-typescript]: test/src/sub/code.spec.ts(11,3): error TS2304: Cannot find name 'it'.
ERROR [compiler.karma-typescript]: test/src/sub/code.spec.ts(16,3): error TS2304: Cannot find name 'it'.

from karma-typescript.

vidartf avatar vidartf commented on June 4, 2024

Updating to latest release (2.1.4) on the initial environment gives same behavior (compiler "errors" that are ignored).

from karma-typescript.

monounity avatar monounity commented on June 4, 2024

Ok, I can reproduce this behavior on windows!

If you want the compiler errors to really be fatal, set noEmitOnError to true, that will make the process exit with ts.ExitStatus.DiagnosticsPresent_OutputsSkipped.

I'm thinking maybe it would be more obvious to output diagnostics as warnings if noEmitOnError is falsy and log the diagnostics as errors and exit if noEmitOnError is set to a truthy value.

from karma-typescript.

monounity avatar monounity commented on June 4, 2024

Your karmaTypescriptConfig.tsconfig points to a file that doesn't exist which seems to throw the compiler off on some systems. I've added a check and a warning if it doesn't exist and now it picks up all files in @types automatically in your example!

from karma-typescript.

vidartf avatar vidartf commented on June 4, 2024

Thanks for the pointer. I've updated the test repo to use the repo version of karma-typescript, and fixed the reference to tsconfig. However, the typings for mocha still fails. I've set up CI on the test repo (appveyor and travis) to help reproduction. The travis build succeeds, while the appveyor one doesn't, so you are right that it seems to be windows specific (typical debug target: backslashes vs slashes in paths). It has the same errors that I have locally, so you can use this to check for fix. See e.g. https://ci.appveyor.com/project/vidartf/karma-ts-test/build/1.0.9.

from karma-typescript.

vidartf avatar vidartf commented on June 4, 2024

(Note that the output from node.js version 6.9 on appveyor doesn't give as much debug output for some reason, but it does locally).

It seems also that the build on travis seem to fail for ver. 4.6, with an error I have also seen locally sometimes on old versions of node:
https://travis-ci.org/vidartf/karma-ts-test/jobs/179604675

ERROR [karma]: [Error: Cannot find module 'buffer/' from '.']
Error: Cannot find module 'buffer/' from '.'

    at Function.module.exports [as sync] (/home/travis/build/vidartf/karma-ts-test/node_modules/karma-typescript/node_modules/browser-resolve/node_modules/resolve/lib/sync.js:33:11)

    at Function.resolve.sync (/home/travis/build/vidartf/karma-ts-test/node_modules/karma-typescript/node_modules/browser-resolve/index.js:321:21)

    at resolveModules (/home/travis/build/vidartf/karma-ts-test/node_modules/karma-typescript/lib/bundlers/builtin/bundler.js:192:45)

    at appendGlobals (/home/travis/build/vidartf/karma-ts-test/node_modules/karma-typescript/lib/bundlers/builtin/bundler.js:116:13)

    at /home/travis/build/vidartf/karma-ts-test/node_modules/karma-typescript/lib/bundlers/builtin/bundler.js:75:9

    at invokeFunc (/home/travis/build/vidartf/karma-ts-test/node_modules/karma-typescript/node_modules/lodash.debounce/index.js:160:19)

    at trailingEdge (/home/travis/build/vidartf/karma-ts-test/node_modules/karma-typescript/node_modules/lodash.debounce/index.js:207:14)

    at timerExpired [as _onTimeout] (/home/travis/build/vidartf/karma-ts-test/node_modules/karma-typescript/node_modules/lodash.debounce/index.js:195:14)

    at Timer.listOnTimeout (timers.js:92:15)

Not sure if this is a known issue.

from karma-typescript.

monounity avatar monounity commented on June 4, 2024

It seems Typescript wants unix slashes in the path to the tsconfig even on windows... Does it work for you with this latest fix?

The error about not finding buffer/ is probably the same issue as in #24 and #28 where npm for some reason won't pull in dependencies correctly, it's a known npm issue affecting lots of users. The only workaround I know of (if you're stuck on a version of Node.js with this problem) is adding each dependency explicitly in the project package.json even though these dependencies already are specified in the package.json of a depending module.

I would go for Node.js v6.9 😃

from karma-typescript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.