question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to add console.log to test source code

See original GitHub issue

I’d like to add console.logs inside my code to see what’s going on.

In as-pect.config.js, I’ve got

	imports: {
		console: {
			log(msg) {
				console.log(msg)
			},
		},
	},

In a globals.d.ts file I have

declare const console: {
	log(a: any): void
}

In my AS source I have things like console.log(whatever) and my IDE doesn’t have any issue with it.

But when I run tests it says

ERROR TS2304: Cannot find name 'console'.

                console.log('HELLO --------------------- ')
   ~~~~~~~

My globals.d.ts is listed in tsconfig.json, and it works fine with asc.

Is there something I have to do for it to work specifically in asp?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
trusktrcommented, Jun 10, 2019

I re-worded my previous to last comment, I didn’t mean to sound too critical! as-pect is super nice already. 😃

0reactions
trusktrcommented, Jun 11, 2019

Cool. Thanks! 🙏 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Test Console Log - DEV Community ‍ ‍
In Jest, we have two ways to verify that console.log was called as we expect it to be. First, we can mock the...
Read more >
Console.log statements output nothing at all in Jest
Run console.debug('Message here', yourValueHere) inside test function and it should show in the console output when running test script. You can verify if...
Read more >
JavaScript Console.log() Example – How to Print to the ...
Just open the console, Ctrl+Shift+K or F12 , and in the top right you will see a button that says "Switch to multi-line...
Read more >
Log messages in the Console - Chrome Developers
# Filter by message source · Click Show Console Sidebar Show Console Sidebar. . The Sidebar. · Click the Expand Expand. icon next...
Read more >
console.log does not output when running tests #2441 - GitHub
Calling console. log using the default testEnvironment of jsdom doesn't print to stdout. If the current behavior is a bug, please provide the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found