Skip to content

Commit

Permalink
feat: Vite Plugin to remove data-testids unless testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Yahatix committed Sep 24, 2023
1 parent 927a300 commit 247356b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ if (process.env.NODE_ENV?.toLowerCase() === 'test') {
nycrcPath: './.nycrc.json',
})
);
} else {
plugins.push({
name: 'remove-testids',
enforce: 'pre',
transform(code, id) {
if (id.endsWith('.svelte')) {
return code.replace(/data-testid=".*?"/g, '');
}
return code;
},
});
}

const config: UserConfig = {
Expand Down

0 comments on commit 247356b

Please sign in to comment.