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 find name 'describe' #8909

Closed
1 task done
Gnorro opened this issue Dec 16, 2017 · 16 comments
Closed
1 task done

Cannot find name 'describe' #8909

Gnorro opened this issue Dec 16, 2017 · 16 comments
Assignees
Labels
needs: more info Reporter must clarify the issue needs: repro steps We cannot reproduce the issue with the information given type: bug/fix

Comments

@Gnorro
Copy link

Gnorro commented Dec 16, 2017

  • bug report

Angular CLI: 1.6.1
Node: 8.2.1
OS: win32 x64
Angular: 5.0.0
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic, router

@angular/cdk: 2.0.0-beta.8
@angular/cli: 1.6.1
@angular/language-service: 4.3.2
@angular/material: 2.0.0-beta.8
@angular/platform-server: 5.1.1
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.42
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.1
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.11
typescript: 2.4.2
webpack: 3.8.1

Repro steps

Follow guide:
https://github.com/angular/angular-cli/wiki/stories-universal-rendering

Observed behavior

I run;
npm run build:ssr && npm run serve:ssr

dist/browser and dist/server are created, server.js is created but when command:
webpack --config webpack.server.config.js --progress --colors
is executed, then i get this error:
ERROR in D:\Test\trunk-angular5-universal\e2e\app.e2e-spec.ts[tsl] ERROR in D:\Test\trunk-angular5-universal\e2e\app.e2e-spec.ts(3,1) TS2304: Cannot find name 'describe'.
ERROR in D:\Test\trunk-angular5-universal\e2e\app.e2e-spec.ts[tsl] ERROR in D:\Test\trunk-angular5-universal\e2e\app.e2e-spec.ts(6,3) TS2304: Cannot find name 'beforeEach'.
ERROR in D:\Test\trunk-angular5-universal\e2e\app.e2e-spec.ts[tsl] ERROR in D:\Test\trunk-angular5-universal\e2e\app.e2e-spec.ts(10,3) TS2304: Cannot find name 'it'.
ERROR in D:\Test\trunk-angular5-universal\e2e\app.e2e-spec.ts[tsl] ERROR in D:\Test\trunk-angular5-universal\e2e\app.e2e-spec.ts(12,5) TS2304: Cannot find name 'expect'.

Desired behavior

No error

Mention any other details that might be useful (optional)

My package.json:
{
"name": "XXX",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server",
"serve:ssr": "node dist/server.js",
"build:client-and-server-bundles": "ng build --prod && ng build --prod --app 1 --output-hashing=false",
"webpack:server": "webpack --config webpack.server.config.js --progress --colors"
},
"private": true,
"dependencies": {
"@agm/core": "1.0.0-beta.2",
"@agm/js-marker-clusterer": "1.0.0-beta.1",
"@angular/animations": "5.0.0",
"@angular/cdk": "2.0.0-beta.8",
"@angular/common": "5.0.0",
"@angular/compiler": "5.0.0",
"@angular/core": "5.0.0",
"@angular/forms": "5.0.0",
"@angular/http": "5.0.0",
"@angular/material": "2.0.0-beta.8",
"@angular/platform-browser": "5.0.0",
"@angular/platform-browser-dynamic": "5.0.0",
"@angular/platform-server": "5.1.1",
"@angular/router": "5.0.0",
"@covalent/core": "1.0.0-beta.5-1",
"@nguniversal/module-map-ngfactory-loader": "5.0.0-beta.5",
"@satispay/web-button-factory": "1.0.4",
"@types/angular": "1.6.28",
"@types/node": "6.0.88",
"braintree-web": "3.22.2",
"braintree-web-drop-in": "1.8.0",
"classlist.js": "1.1.20150312",
"core-js": "2.4.1",
"enhanced-resolve": "3.3.0",
"hammerjs": "2.0.8",
"js-marker-clusterer": "1.0.0",
"lory.js": "2.3.3",
"md5": "2.2.1",
"moment": "2.18.1",
"ng2-cookies": "1.0.12",
"ng2-responsive": "0.8.4",
"ng2-scroll-to-el": "1.0.0",
"paypal-checkout": "4.0.133",
"rxjs": "5.5.2",
"sass-loader": "6.0.6",
"ts-loader": "3.2.0",
"web-animations-js": "2.3.1",
"zone.js": "0.8.16"
},
"devDependencies": {
"@angular/cli": "1.6.1",
"@angular/compiler-cli": "5.0.0",
"@angular/language-service": "4.3.2",
"@types/jasmine": "2.5.45",
"@types/node": "6.0.88",
"codelyzer": "3.0.1",
"jasmine-core": "2.6.4",
"jasmine-spec-reporter": "4.1.1",
"karma": "1.7.0",
"karma-chrome-launcher": "2.1.1",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "1.3.0",
"karma-jasmine": "1.1.0",
"karma-jasmine-html-reporter": "0.2.2",
"ngx-swiper-wrapper": "5.1.0",
"protractor": "5.1.2",
"ts-node": "3.0.6",
"tslint": "5.3.2",
"typescript": "2.4.2",
"webpack": "3.8.1"
}
}

@hansl
Copy link
Contributor

hansl commented Dec 18, 2017

Could you provide a reproduction git repo we could clone? Seems like your tsconfig might be missing types.

@hansl hansl added feature: universal needs: more info Reporter must clarify the issue needs: repro steps We cannot reproduce the issue with the information given type: bug/fix labels Dec 18, 2017
@Gnorro
Copy link
Author

Gnorro commented Dec 19, 2017

Hi Hans

This is my tsconfig:

{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"baseUrl": "src",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"types": [ "node" ],
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2016",
"dom"
]
}
}

For git repo, I should publish my entire production project...

Is my tsconfig enough for the moment?

thanks

@Gnorro
Copy link
Author

Gnorro commented Dec 29, 2017

is there any other info I can give to you, maybe other configuration files or similar?

thanks

@rafiqueshaikh
Copy link

import {} from 'jasmine';

add above line to testing file 'xx.spec.ts' this will save you time..

@Gnorro
Copy link
Author

Gnorro commented Jan 10, 2018

Hi webdoors
Can you explain that please?
Don't understand where I have to add that import. Thanks

@rafiqueshaikh
Copy link

import {} from 'jasmine';

in the test file, like what you are trying to test, like appComponent.spec.ts

@Gnorro
Copy link
Author

Gnorro commented Jan 13, 2018

Thanks Webdoors. This fixed the problem. I put it in file app.e2e-spec.ts
Now I get another error, the same of the one described here:
#8956

@Gnorro Gnorro closed this as completed Jan 13, 2018
@bungbung2
Copy link

@Webdoors
Thanks.
I fixed this problem. your idea is really good.
Can I solve this problem with other configuration files?
such as *.json

@zessu
Copy link

zessu commented Jun 21, 2018

for typescript > 2 just do a npm install --save-dev @types/jasmine
Then in the tsconfig have a

  "typeRoots": [
      "node_modules/@types"
    ],

@strommj
Copy link

strommj commented Dec 26, 2018

Is there a more proper solution to this other than the import {} from 'jasmine' work-around? I'm having these same issues with an angular project which was previously working fine, but now displays the above errors when running ng serve

I have documented my issue on Stack Overflow

@houfu
Copy link

houfu commented Dec 28, 2018

@strommj I don't know if this helps you but I encountered the same problem (typescript service claims there is no 'describe', 'beforeeach' etc even after I checked the @types). ng test was also not locating or executing any tests in my projects. After upgrading my local angular/cli (6.1.5) and global angular/cli (6.2.8) to latest (7.1.4), the errors disappear. Not entirely sure what is happening, but I think the versions can cause confusions.

@meysamsahragard
Copy link

I installed an older version of jasmine with this command:
npm install --save-dev @types/jasmine@2.5.41
and the problem solved.

@alexbenitez
Copy link

alexbenitez commented Jan 7, 2019

@meysamsahragard, in my case I re-installed @types/jasmine@2.8.7 (the version that I already had) and re-started to work. I had tried clearing the cache before this but for some reason that wasn't enough... it was until I re-ran the install --save when finally worked.

We had the problem in two different development machines and solved the same way.

@GeoffMahugu
Copy link

Thanks @meysamsahragard , did npm install --save-dev @types/jasmine@2.5.41 and it worked

@meysamsahragard
Copy link

meysamsahragard commented Jun 12, 2019

Hi @GeoffMahugu. I'm glad that your problem has been resolved.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: more info Reporter must clarify the issue needs: repro steps We cannot reproduce the issue with the information given type: bug/fix
Projects
None yet
Development

No branches or pull requests

10 participants