I am trying to validate a string in which i have to check the not allowed special characters. if it contains not allowed special characters test case should fail. I tried matcher but it only accepts one args. I have a many not allowed special characters(eg:['@','`','!']). Is there any jest matcher in which i can pass array and check whether the array elements are not available in a string?
Matcher
expect(element[keys]).toEqual(expect.not.stringContaining('@'));
You can achieve it using regex
sampleRegex=/[`~@$%^}[\]{|<>]/
expect('sampleString').toEqual(expect.not.stringMatching(sampleRegex));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.