热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Spec上的Karma+TypeScript+jspm404-Karma+TypeScript+jspm404onSpec

Tryingtosetupsometestinginatypescriptproject.Forsomereason,though,Imgettinga404on

Trying to set up some testing in a typescript project. For some reason, though, I'm getting a 404 on the spec file (even though I can see the path is correct). Is there something I'm missing in my Karma configuration file?

尝试在打字稿项目中设置一些测试。但是出于某种原因,我在spec文件上得到了404(尽管我可以看到路径是正确的)。我的Karma配置文件中是否存在我缺少的内容?

module.exports = function(config) {
  config.set({
    basePath: ".",

    frameworks: ["jspm", "jasmine"],
    reporters: ["progress"],
    browsers: ["PhantomJS"],
    files: [

    ],

    proxies: {
      "/test/": "/base/test/",
      "/src/": "/base/src/"
    },

    jspm: {
      stripExtension: false,

      loadFiles: [
        "test/**/*.ts"
      ],
      serveFiles: [
        "src/**/*.ts"
      ]
    },

    preprocessors: {
      "**/*.ts": ["typescript"]
    },

    typescriptPreprocessor: {
      options: {
        noResolve: false,
        module: 'amd'
      },
      transformPath: function(path) {
        return path.replace(/\.ts$/, '.js');
      }
    }
  });
}

Or my config.js file?

还是我的config.js文件?

System.config({
  transpiler: "typescript",
  paths: {
    "github:*": "jspm_packages/github/*",
    "npm:*": "jspm_packages/npm/*"
  },

  map: {
    "typescript": "npm:typescript@1.8.10",
    "github:jspm/nodelibs-os@0.1.0": {
      "os-browserify": "npm:os-browserify@0.1.2"
    },
    "npm:os-browserify@0.1.2": {
      "os": "github:jspm/nodelibs-os@0.1.0"
    },
    "npm:typescript@1.8.10": {
      "os": "github:jspm/nodelibs-os@0.1.0"
    }
  }
});

1 个解决方案

#1


0  

I had the same sort of issue except wasn't using the typescript-preprocessor as I wanted JSPM to handle that. See my question at Karma + JSPM + Typescript - not found '.ts.js' and the repo at https://github.com/Larchy/karma-jspm-typescript-coverage

我有同样的问题,除了没有使用typescript-preprocessor,因为我希望JSPM来处理它。在Karma + JSPM + Typescript上看到我的问题 - 找不到'.ts.js'和https://github.com/Larchy/karma-jspm-typescript-coverage上的回购

Basically added a duplicate package to my jspm config to support karma serving at a higher level

基本上在我的jspm配置中添加了一个重复的包,以支持更高级别的业力

"app": {
  "main": "app",
  "format": "system",
  "defaultExtension": "ts",
  "meta": {
    "*.ts": {
      "loader": "ts"
    }
  }
},
"src/app": {
  "main": "app",
  "defaultExtension": "ts",
  "meta": {
    "*.ts": {
      "loader": "ts"
    }
  }
}

and added proxies to karma config, as you already have:

并添加代理到karma配置,就像你已经拥有的:

proxies : {
    "/base/jspm_packages" : "/base/src/jspm_packages"
},

推荐阅读
author-avatar
经来泓
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有