Code Monkey home page Code Monkey logo

nof5's Introduction

nof5

is a server that runs Unit Tests with the help of test-suites like

on any number of mobile or desktop browsers simultaneously and automatically. nof5 is independent of these test suites and can be used with any suite. Therefore is should be simple to integrate nof5 with existing tests. nof5 is based on

It also supports Web-Bundlers such as

and can be customized to one's own needs with the help of Hooks as

  • before
  • beforeEach

Additionally nof5 supports the xUnit format and can therefore be integrated in Continuous Integration servers such as

Motivation

We originally built nof5 for our client-and server-side framework [alamid.js] (http://alamidjs.com/). [alamid.js] (http://alamidjs.com/) makes it possible that the client code can be written exactly as for the server. We use for the classes of [alamid.js] (http://alamidjs.com/) our JavaScript compiler [nodeclass] (https://npmjs.org/package/nodeclass) and the client-side code will be bundled with the help of [WebPack] (https://github.com/webpack/webpack). We also develop alamid.js using Contiuous integration and Jenkins. There was no tool that combines all these technologies.

Installation

npm install -g nof5

Options

Usage: nof5 [options]

-h, --help            output usage information
-V, --version         output the version number
-d, --debug           outputs some additional debug output, such as a list of watched folders
-s, --silent          run without console logging
--list                lists all bundler names
-p, --port <n>        server port. Default: 11234
-t, --test <dir>      path to test folder. Default: process.cwd()
-l, --lib <dir>       path to lib folder
-a, --assets <dir>    path to folder where additionally files should be also served as statics
-b, --bundler <name>  defines the bundler which should be used. Default: 'Webpack'
-H, --hooks <file>    path to file with hooks
-W, --wphooks <file>  path to file with hooks for webpack-bundler
-B, --bhooks <file>   path to file with hooks for browserify-bundler
-x, --xunit <dir>     path to store xunit.xml file.
-c, --clients <file>  use given client hook

How to use

start nof5

Just execute on command line from test's root folder nof5 or from anywhere nof5 -t path/to/test/folder

hooks

define general hooks (optional)

Define a file named nof5.hooks.js under test's root folder or pass the path to the hooks-file nof5 -H path/to/hooks/file

The hooks-file should look like this:

    exports.before = function beforeHook() {
       //will be executed once
    }

    exports.beforeEach = function() {
       //will be executed each time
    }

define webpack hooks (optional)

Define a file named nof5.webpack.hooks.js under test's root folder or or pass the path to the webpack-hooks-file nof5 -W path/to/webpack/hooks/file

The webpack-hooks.file should look like this:

    exports.use = function () {

        return {
            // webpack-options @see https://github.com/webpack/webpack#options
        };

    }

define browserify hooks (optional)

Define a file named nof5.browserify.hooks.js under test's root folder or or pass the path to the browserify-hooks-file nof5 -B path/to/browserify/hooks/file

The webpack-hooks.file should look like this:

    exports.use = function () {

        "middlewareA": function () {
            //@see https://github.com/substack/node-browserify/blob/master/doc/methods.markdown#busefn
        },

        "middlewareB": function () {
            // ...
        }
    }

Create a Test-Runner

All files under root-folder are served as static files by nof5, so you can use any assets you like, e.g. jQuery, QUnit or Mocha.

     <!-- include socket.io to notify the client that a change on files has occured -->
     <script type="text/javascript" src="/socket.io/socket.io.js"></script>

     <!-- include nof5 which will create a socket and configure it -->
     <script type="text/javascript" src="/nof5.js"></script>

     <!-- load the tests. NOTE: You must execute the tests manually with nof5.enableTests()-->
     <script type="text/javascript" src="tests.js"></script>

     <script>//configure your test-runner</script>

     <script>nof5.enableTests()</script>

See also the example implementation of a Test-Runner.

Use with Jenkins

TODO

nof5's People

Contributors

jhnns avatar matthaias avatar meaku avatar topa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nof5's Issues

nof5 requires vm-browserify on windows

I have totally no idea whats going on here, but when I try to use nof5 on windows /AppData/Roaming/npm/node_modules/nof5/node_modules/browserify/node_modules/vm-browserify/index.js appears in the scripts view. This module doesn't appear when I run nof5 on linux.

Validate JS

Before a new test-bundle is delivered the JavaScript should be validated, so that if for example a SyntaxError has occurred it won't be delivered and it won't break the client's test-runner. This happens sometimes and is annoying, cause you'll have to restart browser manually after something like a SyntaxError has occurred.

xunit-support

It should be possible to run the tests on a set of browsers and write the result to a xunit-file.

Recreate bundle only on change

The bundle is create each time a client requests it. But this not necessary. It should be only recreated if a change has occurred.

Re-running of tests don't work

When I use nof5, the tests aren't re-ran when pressing save. It only works when I create a new file. This occurs in windows and in Linux when using a virtual machine on windows.

Use webpack-dev-middleware

Use the webpack-dev-middleware for serving a webpack bundle.

It may need some more refactoring...

Your current impl has some restrictions:

  • No code splitting, because you only serve one bundle file.
  • Resources emitted in webpack would not be served: require('file/png!./resource.png')
  • Recompilation on each request
  • Only stuff in the specified directory is watched. Check the `bundle-invalid' event emitted from webpack.
  • Changes in loaders are not handled correctly.

Can't establish socket connection when not accessed via localhost

This one is probably easy to fix. The socket connection can't be established when I try to access the test page via another IP than localhost (e.g. when you're using a virtual machine). This is because socket.io tries to connect to localhost nevertheless which IP is used.

I think the best way to fix this would be to use the location-object in the browser to determine the connection's destination.

Params

Provide the possibility to give nof5 some params like:

  • test-folder
  • lib-folder
  • bundler
  • xunit-path

nof5_assets

Sometimes the client tests are split like in alamid's case in shared and client. At the moment there are two assets folders for both tests with nearly the same content like jQuery. But this makes the footprint of tests unnecessary big. Maybe nof5 should provide a automatism like node for modules that tries to find assets in a nof5_assets folder and serves them as static files (without path).

Improve lib-detection

The logic to detect the lib is very simple and should be improved. Also it should be possible to give the path to the lib as param to nof5.

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.