我正在使用通过NPM安装的Jasmine 2.3并使用Grunt执行.
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
package: grunt.file.readJSON('package.json'),
exec: {
jasmine: 'node_modules/.bin/jasmine'
}
});
require('load-grunt-tasks')(grunt);
require('time-grunt')(grunt);
grunt.registerTask('default', 'exec:jasmine');
};
Run Code Online (Sandbox Code Playgroud)
我导出了一个Express.js应用程序对象,并在我的规范中与SuperTest一起使用它.
'use strict';
var supertest = require('supertest')
var application = require('../../../../../server');
describe('GET /api/users', function() {
it('should respond with json', function(done) {
supertest(application)
.get('/api/users')
.set('Accept', 'application/json')
.expect('Content-Type', /json/)
.expect(200, done);
});
});
Run Code Online (Sandbox Code Playgroud)
当我运行规范时,即使200状态代码是预期的并且404是结果,我也没有错误.是Jasmine或SuperTest中的问题,还是我应该使用SuperAgent.
我没有路由设置只是404Express应用程序对象上的错误处理程序设置.
application.use(function(request, response, next) {
response
.status(404)
.send({
message: 'not found'
});
});
Run Code Online (Sandbox Code Playgroud) 当使用PHP SplFileObject和READ_CSV标志迭代csv文件时,我得到一个带有null值的额外行.有没有办法自动删除此行?
$file = new SplFileObject(__DIR__.'/technologies.csv', 'r');
$file->setFlags(SplFileObject::READ_CSV);
foreach ($file as $row) {
var_dump($row);
}
Run Code Online (Sandbox Code Playgroud)
这将生成一个带有null值的行.
...
array(1) {
[0] =>
NULL
}
Run Code Online (Sandbox Code Playgroud)