我正在为我的项目设置nyc / mocha。我想在使用/不使用nyc运行mocha时将--exit
选项传递给mocha。
这是我的packages.json:
"scripts": {
"start": "node ./app",
"test": "./node_modules/.bin/mocha --exit",
"test-with-coverage": "nyc --reporter=html mocha --reporter mochawesome --exit",
"apidoc": "apidoc -i routes/ -o apidocs/"
}
但是当我运行npm test或npm run test-with-coverage时,这会抛出无效选项错误。
如何从npm传递任何选项到mocha?
答案 0 :(得分:1)
我可以看到您显示的代码存在问题的唯一原因是Mocha 4.0.0中添加了class Department
{
[Key]
public int DepartmentId { get; set; }
public string Name { get; set; }
public string Location { get; set; }
public List<Employee> Employees { get; set; }
}
class Employee
{
[Key]
public int Id { get; set; }
[Column("First_Name")]
public string FirstName { get; set; }
[Column("Last_Name")]
public string LastName { get; set; }
public string Gender { get; set; }
public int Salary { get; set; }
public int DepartmentId { get; set; }
[ForeignKey("DepartmentId")]
public Department Department { get; set; }
}
,而您恰好使用的是旧版本。