Skip to content

Is it possible to test if a warning happens? #3029

Answered by SephReed
SephReed asked this question in Q&A
Discussion options

You must be logged in to vote

Got it. Something like this:

const warn = console.warn;
	let gotWarning = false;
	console.warn = (...args: any[]) => {
		const warning = args[0];
		if (typeof warning === "string" && warning.startsWith("A class target has been Sourcified")) {
			gotWarning = true;
		} else {
		}
		warn(...args);
	}
	```

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by SephReed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant