Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot Build loopback4 app without errors #2751

Closed
frost-byte opened this issue Apr 13, 2019 · 5 comments
Closed

Cannot Build loopback4 app without errors #2751

frost-byte opened this issue Apr 13, 2019 · 5 comments
Assignees

Comments

@frost-byte
Copy link

frost-byte commented Apr 13, 2019

Description / Steps to reproduce / Feature proposal

Install LoopBack4
Run lb4 app
Enable all options (specifically tests)

Current Behavior

During the build, when the command tsc --outDir dist --target es2017 runs,
nine errors appear, all related to @types/jest, jest and @types/mocha, mocha

src/__tests__/acceptance/home-page.acceptance.ts:5:1 - error TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.

5 describe('HomePage', () => {


src/__tests__/acceptance/home-page.acceptance.ts:9:3 - error TS2304: Cannot find name 'before'.

9   before('setupApplication', async () => {

src/__tests__/acceptance/home-page.acceptance.ts:13:3 - error TS2304: Cannot find name 'after'.

13   after(async () => {

src/__tests__/acceptance/home-page.acceptance.ts:17:3 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.

17   it('exposes a default home page', async () => {

src/__tests__/acceptance/home-page.acceptance.ts:24:3 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.

24   it('exposes self-hosted explorer', async () => {

src/__tests__/acceptance/ping.controller.acceptance.ts:5:1 - error TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.

5 describe('PingController', () => {

src/__tests__/acceptance/ping.controller.acceptance.ts:9:3 - error TS2304: Cannot find name 'before'.

9   before('setupApplication', async () => {

src/__tests__/acceptance/ping.controller.acceptance.ts:13:3 - error TS2304: Cannot find name 'after'.

13   after(async () => {

src/__tests__/acceptance/ping.controller.acceptance.ts:17:3 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.

17   it('invokes GET /ping', async () => {

Found 9 errors.

Expected Behavior

The build completes without any errors thrown by typescript when the tests are built.

Observations

I did not see anything in the documentation saying that I should globally install mocha, jest and the relevant type files. Installing them globally, or locally in the project directory and then running the command to build the tests then completes without throwing any errors.
Edit Installing mocha, jest and the @types for them does not fix the issue. Deleting the app and recreating it using lb4 appName still shows the same errors. The only way to fix the issues is to install them as dependencies in the project

Environment

Ubuntu 18.04.2 LTS
npm v6.7.0
nodejs 11.14.0

@dhmlau
Copy link
Member

dhmlau commented Apr 14, 2019

@frost-byte , you're right that you don't need to install mocha globally. I assume you accept all options when running lb4 app to create the app?
Could you please check whether you have node_modules folder in the parent directories?
Your error is not the same as #2611, but removing node_modules in the parent directories might help. Thanks.

@dhmlau dhmlau self-assigned this Apr 14, 2019
@dhmlau
Copy link
Member

dhmlau commented Apr 18, 2019

@frost-byte, does the above suggestion help in getting rid of the error? Thanks.

@dhmlau
Copy link
Member

dhmlau commented May 4, 2019

Closing due to inactivity.

@dhmlau dhmlau closed this as completed May 4, 2019
@pSnehanshu
Copy link

I am having the same issue.
Running npm install gives this:

> office-rent-backend@1.0.0 prepare /home/snehanshu/Desktop/office-rent-backend
> npm run build


> office-rent-backend@1.0.0 build /home/snehanshu/Desktop/office-rent-backend
> tsc

src/__tests__/acceptance/home-page.acceptance.ts:5:1 - error TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.

5 describe('HomePage', () => {
  ~~~~~~~~

src/__tests__/acceptance/home-page.acceptance.ts:9:3 - error TS2304: Cannot find name 'before'.

9   before('setupApplication', async () => {
    ~~~~~~

src/__tests__/acceptance/home-page.acceptance.ts:13:3 - error TS2304: Cannot find name 'after'.

13   after(async () => {
     ~~~~~

src/__tests__/acceptance/home-page.acceptance.ts:17:3 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.

17   it('exposes a default home page', async () => {
     ~~

src/__tests__/acceptance/home-page.acceptance.ts:24:3 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.

24   it('exposes self-hosted explorer', async () => {
     ~~

src/__tests__/acceptance/ping.controller.acceptance.ts:5:1 - error TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.

5 describe('PingController', () => {
  ~~~~~~~~

src/__tests__/acceptance/ping.controller.acceptance.ts:9:3 - error TS2304: Cannot find name 'before'.

9   before('setupApplication', async () => {
    ~~~~~~

src/__tests__/acceptance/ping.controller.acceptance.ts:13:3 - error TS2304: Cannot find name 'after'.

13   after(async () => {
     ~~~~~

src/__tests__/acceptance/ping.controller.acceptance.ts:17:3 - error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.

17   it('invokes GET /ping', async () => {
     ~~


Found 9 errors.

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! office-rent-backend@1.0.0 build: `tsc`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the office-rent-backend@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/snehanshu/.npm/_logs/2019-11-04T18_35_49_946Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! office-rent-backend@1.0.0 prepare: `npm run build`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the office-rent-backend@1.0.0 prepare script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/snehanshu/.npm/_logs/2019-11-04T18_35_49_961Z-debug.log

@pSnehanshu
Copy link

Installing @types/jest and @types/mocha solved the issue, wondering why they aren't installed by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants