diff --git a/packages/javascript-mutator/src/helpers/BabelHelper.ts b/packages/javascript-mutator/src/helpers/BabelHelper.ts index 917a308ce6..80101d56b7 100644 --- a/packages/javascript-mutator/src/helpers/BabelHelper.ts +++ b/packages/javascript-mutator/src/helpers/BabelHelper.ts @@ -19,7 +19,8 @@ export default class BabelHelper { 'dynamicImport', 'flow', 'jsx', - 'objectRestSpread' + 'objectRestSpread', + ['decorators', { decoratorsBeforeExport: true }] as any, ], sourceType: 'unambiguous' }; diff --git a/packages/javascript-mutator/test/unit/JavaScriptMutator.spec.ts b/packages/javascript-mutator/test/unit/JavaScriptMutator.spec.ts index adb3111949..6d1202e896 100644 --- a/packages/javascript-mutator/test/unit/JavaScriptMutator.spec.ts +++ b/packages/javascript-mutator/test/unit/JavaScriptMutator.spec.ts @@ -151,4 +151,17 @@ describe('JavaScriptMutator', () => { expect(mutants.length).to.equal(2); }); + + it('should generate mutants when file contains a decorator', () => { + const sut = createSut(); + const files: File[] = [new File('testFile.js', ` + @decorator() + export class Foo { + bar = 'bar'; + }; + `)]; + + const mutants = sut.mutate(files); + expect(mutants).lengthOf.above(0); + }); });