Skip to content

Instantly share code, notes, and snippets.

@jzerbe
Created March 22, 2015 17:03
Show Gist options
  • Select an option

  • Save jzerbe/083994efc0bcdb043660 to your computer and use it in GitHub Desktop.

Select an option

Save jzerbe/083994efc0bcdb043660 to your computer and use it in GitHub Desktop.

Revisions

  1. jzerbe created this gist Mar 22, 2015.
    34 changes: 34 additions & 0 deletions karma.conf.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    module.exports = function(config) {
    config.set({
    browsers: ["PhantomJS"],
    coverageReporter: {
    dir: 'report/coverage/',
    reporters: [
    {type: 'html', subdir: 'html'},
    {type: 'text'}
    ]
    },
    exclude: ['build/src/annotation_upload_*.js'],
    files: [
    'build/src/SupportedMethods.js',
    'build/src/Interfaces/*.js',
    'build/src/Bundle/*.js',
    'build/src/Task/Base.js',
    'build/src/**/*.js',
    'build/test/**/*.js'
    ],
    frameworks: ['jasmine'],
    junitReporter: {
    outputFile: './test/results.xml'
    },
    logLevel: config.LOG_DEBUG,
    preprocessors: {
    'build/src/**/*.js': ['coverage']
    },
    proxies: {
    '/api': 'http://localhost:3000/api'
    },
    reporters: ['coverage', 'junit', 'progress'],
    singleRun: true
    });
    };
    37 changes: 37 additions & 0 deletions server.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    var type_key = 'Content-Type';
    var type_json = 'application/json';

    var prefix_request_in = '[test backend]: request received for';
    var prefix_response_out = '[test backend]: response sent for';

    var express = require('express');
    var app = express();

    // test/Task/CooThing.spec.ts
    app.get('/api/v1.0/namespace/service/model/*resource_id*', function (req, res) {
    console.log('%s namespace bundle', prefix_request_in);
    res.set(type_key, type_json).send(
    {
    "status": 200,
    "reason": "OK",
    "messages": [],
    "result": 'string'
    }
    );
    console.log('%s namespace bundle', prefix_response_out);
    });

    // start the server
    var server = app.listen(3000, function () {
    var host = server.address().address;
    var port = server.address().port;
    console.log('[test backend]: listening at http://%s:%s', host, port);
    });

    // server KILL handler for graceful shutdown
    process.on('SIGTERM', function () {
    console.log('[test backend]: stopping');
    server.close();
    console.log('[test backend]: stopped');
    process.exit();
    });
    5 changes: 5 additions & 0 deletions server_stop.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    #!/bin/bash

    ps aux | grep 'server.js' | grep 'node' | awk '{ print $2 }' | xargs kill

    exit 0