我正在编写我的第一个包,我只是将它转换为与 TypeScript 兼容,但这在某种程度上影响了我的 GitHub 工作流程。当我在本地使用 Jest 运行我的测试时,它们工作得很好。当我的测试在 GitHub 上运行时,它成功了10.x,但没有12.x或14.x,给我以下错误:
(node:2397) ExperimentalWarning: The ESM module loader is experimental.
ReferenceError: module is not defined
at file:///home/runner/work/enhancedMathJS/enhancedMathJS/jest.config.js:1:1
at ModuleJob.run (internal/modules/esm/module_job.js:146:37)
at async Loader.import (internal/modules/esm/loader.js:182:24)
at async readConfigFileAndSetRootDir (/home/runner/work/enhancedMathJS/enhancedMathJS/node_modules/jest-config/build/readConfigFileAndSetRootDir.js:126:32)
at async readConfig (/home/runner/work/enhancedMathJS/enhancedMathJS/node_modules/jest-config/build/index.js:217:18)
at async readConfigs (/home/runner/work/enhancedMathJS/enhancedMathJS/node_modules/jest-config/build/index.js:406:26)
at async runCLI (/home/runner/work/enhancedMathJS/enhancedMathJS/node_modules/@jest/core/build/cli/index.js:230:59)
at async Object.run (/home/runner/work/enhancedMathJS/enhancedMathJS/node_modules/jest/node_modules/jest-cli/build/cli/index.js:163:37)
npm ERR! Test failed. See above for more details.
enhancedmath@2.0.0 test /home/runner/work/enhancedMathJS/enhancedMathJS
jest
Run Code Online (Sandbox Code Playgroud)
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: …Run Code Online (Sandbox Code Playgroud) 昨天我来问她一个类似的问题,关于我自己的实体类型会出现一些错误。我修复了这些错误,但是现在它在实体类型字符串上抛出了一个错误,我绝对不知道如何解决此错误。
完全例外:
System.InvalidOperationException:'找不到适用于实体类型'string'的合适的构造函数。以下参数无法绑定到实体的属性:“值”,“值”,“ startIndex”,“长度”,“值”,“值”,“ startIndex”,“长度”,“值”,“值”,“ startIndex”,“长度”,“值”,“ startIndex”,“长度”,“ enc”,“ c”,“计数”,“值”。
启动应用程序时会抛出此错误:我编写了一个数据播种器以在数据库中获取一些数据。我已经在我的类范围内,ConfigureServices并在Configure方法中使用它。
public void ConfigureServices(IServiceCollection services) {
services.Configure<CookiePolicyOptions>(options => {
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")));
services.AddScoped<IRatingRepository, RatingRepository>();
services.AddScoped<IReservationRepository, ReservationRepository>();
services.AddScoped<DataSeeder>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment …Run Code Online (Sandbox Code Playgroud) 我正在尝试设置一个测试环境来测试我的 typescript Express Nodejs 端点,但我似乎无法让它工作。我已经安装了:
这是规范文件的样子:
import * as request from 'supertest';
import seed from '../../modules/contract/seed'; //empty seed function
import app from '../../index'; // export default app which is an express()
beforeAll(seed);
describe('contractService', () => {
it('getContracts ', async () => {
const res = await request(app).get('/getContracts');
console.log(res.body);
});
it('makeContract makes and returns a new contract', async () => {
const res = await request(app)
.post('/makeContract')
.send({
name: 'testContract',
startDate: '2019-10-3',
challenges: []
}); …Run Code Online (Sandbox Code Playgroud) 我对 DevOps 的世界真的很陌生,我想把我的脚趾浸入水中。这就是为什么我一直在尝试设置一个简单的 GitHub Action,当我推送到 master 时,我的站点会自动部署到 Firebase,但在构建阶段出现问题:
Run npm run build
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/runner/work/ChezMout/ChezMout/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/runner/work/ChezMout/ChezMout/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2020-01-12T12_04_27_341Z-debug.log
##[error]Process completed with exit code 254.
Run Code Online (Sandbox Code Playgroud)
这是我的基本工作流程:
name: …Run Code Online (Sandbox Code Playgroud) 对于学校,我们必须使用 .NET Entity Core Framework 编写我们自己的 WebApi。我已经编写了我的 api,但是当我尝试在 swagger 中使用它时,它总是返回一个 HTTP 500 错误:内部服务器错误。我下载了 Fiddler 以开始调试,并在我的存储库中遇到了循环依赖错误,但我无法弄清楚这会发生在哪里。
接口(用于模拟测试)
public interface IVisitorRepository
{
Visitor GetBy(string email);
void AddVisitor(Visitor visitor);
void SaveChanges();
}
Run Code Online (Sandbox Code Playgroud)
具体类
public class VisitorRepository : IVisitorRepository
{
private readonly ApplicationDbContext _context;
private readonly DbSet<Visitor> _visitors;
public VisitorRepository(ApplicationDbContext context, IVisitorRepository visitorRepository)
{
_context = context;
_visitors = _context.Visitors;
}
public void AddVisitor(Visitor visitor)
{
_visitors.Add(visitor);
}
public Visitor GetBy(string email)
{
return _visitors.SingleOrDefault(v => v.Email == email);
}
public void SaveChanges()
{ …Run Code Online (Sandbox Code Playgroud) 我收到此异常:
System.InvalidOperationException HResult=0x80131509 消息=找不到适合实体类型“MyImage”的构造函数。以下构造函数的参数无法绑定到实体类型的属性:无法在“MyImage(string name, string country, Image image)”中绑定“image”。Source=Microsoft.EntityFrameworkCore StackTrace:在 Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConstructorBindingConvention.Apply(InternalModelBuilder modelBuilder) 在 Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.ImmediateConventionFrame.OnModelBuilt(InternalModelBuilder modelBuilder) 在 Microsoft.Core Microsoft.EntityFrameworkCore 中的 Metadata.Conventions.Internal.ConventionDispatcher.OnModelBuilt(InternalModelBuilder modelBuilder)。
1.ViaFactory(LazyThreadSafetyMode mode) at System.Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) at System.Lazy1.CreateValue() at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.GetModel(DbContext context, IConventionSetBuilder conventionSetBuilder, IModelValidator validator) at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel() at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model() at Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder.<>c.<TryAddCoreServices>b__7_2(IServiceProvider p) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, ServiceProviderEngineScope scope) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(IServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRuntimeResolver.VisitScopes.VisitScoped. ServiceLookup.CallSiteVisitor2.VisitCallSite(IServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(IServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope) …
我想知道是否应该将 rc 文件(例如.prettierrc或 ).firebaserc和其他配置文件(例如.editorconfigGitHub)提交到 GitHub?
我正在寻找用[,,]的值填充数组中的空白点null。如果有 2 个,,我需要 3 个元素
我也希望它能在数组如下所示的情况下工作:[value,,]或[, value,]或[,,value]
if (Object.values(row).length !== row.length) {
let newRow: any[];
newRow = row.map(el => {
if (el) {
return el;
} else {
return 'null';
}
});
console.log('newRow:: ', newRow);
return newRow;
}
Run Code Online (Sandbox Code Playgroud)