From f0dd4303d0bdfc77b554b9a45cd004d53c271f90 Mon Sep 17 00:00:00 2001 From: Nico Jansen Date: Thu, 4 Apr 2019 08:32:47 +0200 Subject: [PATCH] feat(javascript-mutator): allow decorators (#1474) --- .../javascript-mutator/src/helpers/BabelHelper.ts | 3 ++- .../test/unit/JavaScriptMutator.spec.ts | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) 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); + }); });