Am using Jasmine karma in angular-cli project.
When am trying to use a json file inside it throws an error.
import { TestBed } from '@angular/core/testing';
describe('xxxService', () => {
let service: xxxService
let attributeData: any = require('../../mock-data/testCase_mockData/attributedata.json');
beforeEach(()=>{
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [xxxService],
});
service = TestBed.get(ColorCodeEngineService);
// attributeData = Object.assign({}, require('../../mock-data/testCase_mockData/attributedata.json'));
});
});
It throws error ,
ERROR in ./src/app/mock-data/testCase_mockData/attributedata.json Module parse failed: Unexpected end of JSON input while parsing near '' You may need an appropriate loader to handle this file type. SyntaxError: Unexpected end of JSON input while parsing near ''
Is there any solutions to fix this ?