代码之家  ›  专栏  ›  技术社区  ›  Roman T

为什么specrunner.html不能解析TypeScript生成的spec.js?

  •  0
  • Roman T  · 技术社区  · 1 年前

    我在VS Code中的Jasmine框架中工作,其中包含TypeScript文件( .ts ) 以及相应的规格( .spec ).运行后 npm build test ,预期的JavaScript文件 ( .js .spec.js )生成。这是从生成的代码 .spec.js :

    var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
            function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
            });
    };
    import { greet } from './helloWorld';
    describe('greet function', () => {
        it('should return "Hello, World!"', () => __awaiter(void 0, void 0, void 0, function* () {
            const message = yield greet();
            expect(message).toBe('Hello, World!');
        }));
    });
    

    然而 specrunner.html 遇到错误” 加载过程中出错: 意外的令牌 “在尝试加载生成的 spec.js 文件

    0 回复  |  直到 1 年前