Since a "word" in your scenario is a chunk of one or more non-whitespace chars (and a non-whitespace char is matched with \S in regex) you can use
console.log(
"Hello this is testing _testisgood _test test ilovetesting again test"
.match(/\S+test\S*|\S*test\S+/gi))
// => ["testing","_testisgood", "_test", "ilovetesting"]
Here, \S+test\S*|\S*test\S+ (see this regex demo) matches either
\S+test\S* - one or more non-whitespace chars, test and zero or more non-whitespace chars
| - or
\S*test\S+ - zero or more non-whitespace chars, test and one or more non-whitespace chars.
Or, you can split with any one or more whitespace chars (with .split(/\s+/)) and then filter out any chunk that is equal to test string or does not contain test string:
console.log(
"Hello this is testing _testisgood _test test ilovetesting again test".split(/\s+/)
.filter(x => x.toLowerCase() != "test" && x.toLowerCase().includes("test")))
Considering your expected output it may seem that you want to match any non-whitespace chunk that contains test and at least one more letter. In that case, you can use
console.log(
"Hello this is testing _testisgood _test test ilovetesting again test"
.match(/[^\sa-zA-Z]*[a-zA-Z]\S*test\S*|\S*test[^\sa-zA-Z]*[a-zA-Z]\S*/gi))
// => ["testing","_testisgood", "_test", "ilovetesting"]
See this regex demo. Output: ["testing", "_testisgood", "ilovetesting"]
Details:
[^\sa-zA-Z]* - any zero or more chars other than whitespace and letters
[a-zA-Z] - a letter
\S*test\S* - test enclosed with zero or more non-whitespace chars
| - or
\S*test[^\sa-zA-Z]*[a-zA-Z]\S* - zero or more non-whitespace chars, test, any zero or more chars other than whitespace and letters and then a letter and zero or more non-whitespace chars.
_test? it doesn't come afterwhitespace"testing"is a match, surrounded seems like the wrong word and I don't know what "opposite of exact match" means (an "inexact match"?). You need to state the problem more precisely, such as "I wish to match 'test' when it is (not preceded by a ???) and is (not followed by a ???)" or ".... when it is (preceded by a ???) and is (followed by a ???)".