diff --git a/modules/schematics/src/store/index.spec.ts b/modules/schematics/src/store/index.spec.ts index 90363eebbf..0b24d48aa5 100644 --- a/modules/schematics/src/store/index.spec.ts +++ b/modules/schematics/src/store/index.spec.ts @@ -238,4 +238,14 @@ describe('Store Schematic', () => { schematicRunner.runSchematic('store', options, appTree); }).not.toThrow(); }); + + it('should add store runtime checks', () => { + const options = { ...defaultOptions, module: 'app.module.ts' }; + + const tree = schematicRunner.runSchematic('store', options, appTree); + const content = tree.readContent(`${projectPath}/src/app/app.module.ts`); + expect(content).toMatch(/, runtimeChecks: {/); + expect(content).toMatch(/strictStateImmutability: true,/); + expect(content).toMatch(/strictActionImmutability: true/); + }); }); diff --git a/modules/schematics/src/store/index.ts b/modules/schematics/src/store/index.ts index 51c67a4935..a45e4da217 100644 --- a/modules/schematics/src/store/index.ts +++ b/modules/schematics/src/store/index.ts @@ -61,11 +61,16 @@ function addImportToNgModule(options: StoreOptions): Rule { `${options.path}/environments/environment` ); + const runtimeChecks = `runtimeChecks: { + strictStateImmutability: true, + strictActionImmutability: true, + }`; + const storeNgModuleImport = addImportToModule( source, modulePath, options.root - ? `StoreModule.forRoot(reducers, { metaReducers })` + ? `StoreModule.forRoot(reducers, { metaReducers, ${runtimeChecks} })` : `StoreModule.forFeature('${stringUtils.camelize( options.name )}', from${stringUtils.classify(