gpt4 book ai didi

jasmine - 如何在 Cloud9 中使用 Jasmine?

转载 作者:行者123 更新时间:2023-12-01 12:59:27 26 4
gpt4 key购买 nike

我经常使用 Jasmine(JavaScript 的 BDD)并且刚刚发现 Cloud9 并想尝试一下。

在我的本地机器上,我使用 jasmine-node 来运行我的规范,但我不知道如何在 Cloud9 中执行此操作。我能够使用 Cloud9 编辑器底部的控制台栏通过 npm 以某种方式安装 jasmine-node,但我无法使用它。

我用 CoffeeScript 编写代码,但这应该不是问题,我也试过 JavaScript。

最佳答案

将 run-tests.js 文件添加到包含 jasmine-node 脚本改编的项目。在此示例中,生产代码位于与 run-tests.js 文件平行的 lib 文件夹下。

运行配置:

File path:              run-tests.js
Command line arguments: --coffee spec

运行测试.js

if( !process.env.NODE_ENV ) process.env.NODE_ENV = 'test';

var path = require('path');

// find out the current paths
//console.log(require.paths);
// I have ~/.node_modules in there, which did not exist and did a
// ln -s ~/local/lib/node_modules/ ~/.node_modules
// my jasmine-node/cli.js is in
// ~/local/lib/node_modules/jasmine-node/lib/jasmine-node/cli.js

// Add the local lib path to allow the specs to require from there
require.paths.unshift(path.join(__dirname, 'lib'));

require('jasmine-node/lib/jasmine-node/cli.js');

关于jasmine - 如何在 Cloud9 中使用 Jasmine?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7450568/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com