jeudi 12 octobre 2017

How do I prevent ENOENT error while running `npm test` in my tfs build?

I'm trying to run npm test in my tfs build, but I get everytime I get an ENOENT error:

C:\Program Files\nodejs\npm.cmd run test

npm ERR! path E:\Agents\agent_work\38\package.json

npm ERR! code ENOENT

npm ERR! errno -4058

npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open 'E:\Agents\agent_work\38\package.json'

npm ERR! enoent This is related to npm not being able to find a file.

I followed this tutorial of Microsoft to set up my build and I also included npm cache clean, because I read that if you get enoent during install that might fix it.

When I run npm test locally it works fine

Below are my config files.

This is karma.config.js:

module.exports = function (config) {
    var testWebpackConfig = require('./webpack.test.js');
  config.set({

    basePath: '.',
    frameworks: ['jasmine'],

    plugins: [
        require('karma-jasmine'),
        require('karma-phantomjs-launcher'),
        require('karma-webpack'),
        require('karma-sourcemap-loader'),
        require('karma-jasmine-html-reporter'),
        require('karma-junit-reporter')
    ],

    // list of files / patterns to load in the browser
    files: [
        { pattern: 'spec.bundle.js', watched: false }
    ],

    preprocessors: {
        'spec.bundle.js': ['webpack', 'sourcemap']
    },

    // webpack
    webpack: testWebpackConfig,

    reporters: ['progress', 'kjhtml', 'junit'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['PhantomJS'],
    singleRun: false,
    concurrency: Infinity,
    junitReport: {
        outputDir: '',
        outputFile: 'test.xml'
    }
  })
}

This is spec.bundle.js:

import 'core-js';
import 'zone.js/dist/zone';
import 'http://ift.tt/2bzdqQw';
import 'http://ift.tt/2c7PMID';
import 'http://ift.tt/2cuTs9G';
import 'http://ift.tt/2bD0xlP';
import 'http://ift.tt/2bzdzU8';
import 'http://ift.tt/2bD0Rkt';

import { getTestBed } from '@angular/core/testing';
import {
    BrowserDynamicTestingModule,
    platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';

import 'rxjs';

getTestBed().initTestEnvironment(
    BrowserDynamicTestingModule,
    platformBrowserDynamicTesting()
);

var testContext = require.context('./src', true, /\.spec\.ts/);

function requireAll(requireContext) {
    return requireContext.keys().map(requireContext);
}

var modules = requireAll(testContext);

Aucun commentaire:

Enregistrer un commentaire