This regular expression is used on next.config.js
and is used to remove test attributes from the production build.
It filters any data attributes that starts with 'test', 'cy' or 'jest'.
Inputs: <span data-test="test1">SPAN 1</span> <span data-testid="test1">SPAN 2</span> <span data-test-id="test1">SPAN 3</span>
Outputs: <span>SPAN 1</span> <span>SPAN 2</span> <span>SPAN 3</span>
Inputs: <span data-jest="test1">SPAN 1</span> <span data-jestid="test1">SPAN 2</span> <span data-jest-id="test1">SPAN 3</span>
Outputs: <span>SPAN 1</span> <span>SPAN 2</span> <span>SPAN 3</span>
Inputs: <span data-cy="test1">SPAN 1</span> <span data-cyid="test1">SPAN 2</span> <span data-cy-id="test1">SPAN 3</span>
Outputs: <span>SPAN 1</span> <span>SPAN 2</span> <span>SPAN 3</span>
module.exports = {
compiler: {
// The regexes defined here are processed in Rust so the syntax is different from
// JavaScript `RegExp`s. See https://docs.rs/regex.
reactRemoveProperties: { properties: ['^data-(test|cy|jest).*$'] },
},
}