cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAP CAP Jest - Syntax Error Issue

sandeepmalhotra
Participant
0 Likes
572

Hello Experts,

I am trying to run jest test case as mentioned in the hello folder of the cloud-cap-samples

Please make a note that am using Typescript with SAP CAP which working fine. But Jest Test case is not working

Code has copied from cloud-cap-samples only

world.cds

service say { function hello(to : String) returns String;}

world.ts

import type { Request } from "@sap/cds/apis/services"
module.exports = class say {
hello(req: Request) {
return `Hello ${req.data.to} from a TypeScript file!`
}
}

hello-world-test.js

const cds = require('@sap/cds')
describe('Hello world!', () => {
beforeAll(() => process.env.CDS_TYPESCRIPT = true)
afterAll(() => delete process.env.CDS_TYPESCRIPT)
const { GET } = cds.test.in(__dirname, '../srv').run('serve', 'world.cds')
it('should say hello with class impl', async () => {
const { data } = await GET`/say/hello(to='world')`
expect(data.value).toMatch(/Hello world.*typescript.*/i)
})
})


 "jest": { "testMatch": [ "**/*-test.js" ], "testTimeout": 20000 },
  

I am getting below mentioned error

Kindly let me know if am missing any thing here

Thanks

Sandeep

Accepted Solutions (0)

Answers (2)

Answers (2)

sandeepmalhotra
Participant
0 Likes

I will give a try and let you know thanks

Yogananda
Product and Topic Expert
Product and Topic Expert
0 Likes