Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

karma-dart

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

karma-dart

A Karma plugin - adapter for Dart unittest testing framework.

  • 0.1.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
increased by1000%
Maintainers
1
Weekly downloads
 
Created
Source

Adapter for the Dart unittest testing framework.

For more information on Karma-runner see the homepage.

Getting Started

You'll need node.js: http://nodejs.org/download/

Install karma and karma-dart adapter npms:

npm install karma@canary karma-dart@canary

Refer to npm install documentation for more details and install options.

and you'll need the following dependencies in your pubspec.yaml

unittest: any
browser: any
js: any

The following is an example of karma config.

module.exports = function(karma) {
  karma.configure({
    basePath: '.',
    frameworks: ['dart-unittest'],

    // list of files / patterns to load in the browser
    // all tests must be 'included', but all other libraries must be 'served' and
    // optionally 'watched' only.
    files: [
      'test/*.dart',
      {pattern: '**/*.dart', watched: true, included: false, served: true},
      'packages/browser/dart.js',
      'packages/browser/interop.js'
    ],

    autoWatch: true,

    // If browser does not capture in given timeout [ms], kill it
    captureTimeout: 5000,

    plugins: [
      'karma-dart'
    ]
  });
};

You can run karma from the local folder:

node node_modules/karma/bin/karma start karma-dart.conf

or if you installed it with -g flag just

karma start karma-dart.conf

Then just open http://localhost:9876/ in Dartium.

Testing Web Components

karma-dart adapter does not invoke DWC compiler, however it will detect changes to generated files and run your tests automatically.

When using Dart Editor, it will automatically invoke DWC compiler when you change the HTML/dart files and write them to the "web/out" folder. Just make sure your tests import files from the out folder, and your karma config serves/watches dart file in the out folder as well.

library click_counter_test;

import 'package:unittest/unittest.dart';
import 'dart:html';
import '../web/out/xclickcounter.dart';

main() {
  test('CounterComponent.increment', () {
    var hello = new DivElement();
    var component = new CounterComponent.forElement(hello);
    expect(component.count, equals(0));
    component.increment();
    expect(component.count, equals(1));
  });
}

Known Limitations/Issues

  • Missing support for dart2js use-case.
  • Missing Dartium launcher.
  • Each test file must be a library -- due to the nature of the test runner, this is required.
  • When Dart syntax error is encountered, karma SOMETIMES gets stuck until captureTimeout. There is no way to work around this until https://code.google.com/p/dart/issues/detail?id=5958

Keywords

FAQs

Package last updated on 01 Aug 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc