How to use parseConfigStub method in stryker-parent

Best JavaScript code snippet using stryker-parent

builder.spec.ts

Source:builder.spec.ts Github

copy

Full Screen

1import { expect, use as chaiUse } from 'chai';2import chaiAsPromised from 'chai-as-promised';3import chaiExclude from 'chai-exclude';4import { BuildOptions } from 'esbuild';5import fs from 'fs/promises';6import mockFS from 'mock-fs';7import path from 'path';8import sinon from 'sinon';9import { ZodError } from 'zod';10import { build, watch } from './builder';11import * as configLoader from './config-loader';12import { InvalidConfigError, NoEntryPointsError, ProjectDirectoryNotFoundError } from './errors';13import * as esbuild from './helper/esbuild';14import * as glob from './helper/glob';15import * as logger from './helper/logger';16import * as rimraf from './helper/rimraf';17import { BuilderConfigType, WatchConfigType } from './models';18import * as shimPlugin from './plugins/shim.plugin';19import * as shims from './shims';20/* eslint-disable @typescript-eslint/no-explicit-any */21chaiUse(chaiAsPromised);22chaiUse(chaiExclude);23const expectedDefaultConfig: BuildOptions = {24 bundle: true,25 format: 'esm',26 minify: true,27 outdir: 'dist',28 outExtension: { '.js': '.mjs' },29 platform: 'node',30 sourcemap: false,31 splitting: true,32 target: 'node12',33 watch: false,34 write: false,35};36const projectDir = 'my/project';37describe('Builder', () => {38 let sandbox: sinon.SinonSandbox;39 let esbuildStub: sinon.SinonStub;40 let parseConfigStub: sinon.SinonStub;41 let globStub: sinon.SinonStub;42 let rimrafStub: sinon.SinonStub;43 let shimPluginStub: sinon.SinonStub;44 let mockLogger: {45 error: sinon.SinonStub;46 warn: sinon.SinonStub;47 info: sinon.SinonStub;48 verbose: sinon.SinonStub;49 };50 beforeEach(() => {51 sandbox = sinon.createSandbox();52 mockFS({53 [projectDir]: mockFS.directory(),54 });55 mockLogger = {56 error: sandbox.stub(),57 warn: sandbox.stub(),58 info: sandbox.stub(),59 verbose: sandbox.stub(),60 };61 esbuildStub = sandbox.stub(esbuild, 'build').resolves({ outputFiles: [], errors: [], warnings: [] });62 parseConfigStub = sandbox.stub(configLoader, 'parseConfig');63 globStub = sandbox.stub(glob, 'glob').resolves([]);64 rimrafStub = sandbox.stub(rimraf, 'rimraf').resolves();65 shimPluginStub = sandbox.stub(shimPlugin, 'shimPlugin').returns('shimPluginStub' as any);66 sandbox.stub(logger, 'createLogger').returns(mockLogger);67 });68 afterEach(() => {69 sandbox.restore();70 mockFS.restore();71 });72 describe('build', () => {73 it('should parse config', async () => {74 const config: BuilderConfigType = {75 project: projectDir,76 entryPoints: ['func/index.ts'],77 clean: true,78 };79 parseConfigStub.returns(config);80 await build(config);81 expect(parseConfigStub.calledOnce).to.be.true;82 expect(parseConfigStub.firstCall.args[0]).to.eql(config);83 });84 it('should call esbuild.build with correct config when entryPoints were supplied', async () => {85 const entryPoints = ['func1/index.ts', 'func2/index.ts'];86 const config: BuilderConfigType = {87 project: projectDir,88 entryPoints,89 };90 parseConfigStub.returns(config);91 await build(config);92 expect(globStub.called).to.be.false;93 expect(rimrafStub.called).to.be.false;94 expect(shimPluginStub.called).to.be.false;95 expect(esbuildStub.calledOnce).to.be.true;96 expect(esbuildStub.firstCall.args[0]).to.eql({97 ...expectedDefaultConfig,98 entryPoints: entryPoints.map(entryPoint => `${process.cwd()}/${projectDir}/${entryPoint}`),99 plugins: [],100 });101 });102 it('should call esbuild.build with correct config when esbuildOptions were supplied', async () => {103 const entryPoints = ['func1/index.ts', 'func2/index.ts'];104 const config: BuilderConfigType = {105 project: projectDir,106 entryPoints,107 esbuildOptions: {108 outdir: 'something',109 },110 };111 parseConfigStub.returns(config);112 await build(config);113 expect(globStub.called).to.be.false;114 expect(rimrafStub.called).to.be.false;115 expect(shimPluginStub.called).to.be.false;116 expect(esbuildStub.calledOnce).to.be.true;117 expect(esbuildStub.firstCall.args[0]).to.eql({118 ...expectedDefaultConfig,119 ...config.esbuildOptions,120 entryPoints: entryPoints.map(entryPoint => `${process.cwd()}/${projectDir}/${entryPoint}`),121 plugins: [],122 });123 });124 it('should glob all index.ts files when no entryPoints were supplied', async () => {125 const config: BuilderConfigType = {126 project: projectDir,127 esbuildOptions: {128 outdir: 'something',129 },130 };131 const files = [`${process.cwd()}/${projectDir}/func1/index.ts`, `${process.cwd()}/${projectDir}/func2/index.ts`];132 globStub.resolves(files);133 parseConfigStub.returns(config);134 await build(config);135 expect(rimrafStub.called).to.be.false;136 expect(shimPluginStub.called).to.be.false;137 expect(esbuildStub.calledOnce).to.be.true;138 expect(esbuildStub.firstCall.args[0]).to.eql({139 ...expectedDefaultConfig,140 ...config.esbuildOptions,141 entryPoints: files,142 plugins: [],143 });144 expect(globStub.calledOnce).to.be.true;145 expect(globStub.firstCall.args).to.eql([146 '**/index.ts',147 {148 cwd: projectDir,149 absolute: true,150 ignore: ['**/node_modules/**'],151 },152 ]);153 });154 it('should glob all index.ts files when no entryPoints but excludes were supplied', async () => {155 const config: BuilderConfigType = {156 project: projectDir,157 exclude: ['dir1'],158 esbuildOptions: {159 outdir: 'something',160 },161 };162 const files = [`${process.cwd()}/${projectDir}/func1/index.ts`, `${process.cwd()}/${projectDir}/func2/index.ts`];163 globStub.resolves(files);164 parseConfigStub.returns(config);165 await build(config);166 expect(rimrafStub.called).to.be.false;167 expect(shimPluginStub.called).to.be.false;168 expect(esbuildStub.calledOnce).to.be.true;169 expect(esbuildStub.firstCall.args[0]).to.eql({170 ...expectedDefaultConfig,171 ...config.esbuildOptions,172 entryPoints: files,173 plugins: [],174 });175 expect(globStub.calledOnce).to.be.true;176 expect(globStub.firstCall.args).to.eql([177 '**/index.ts',178 {179 cwd: projectDir,180 absolute: true,181 ignore: ['**/node_modules/**', ...config.exclude!],182 },183 ]);184 });185 it('should rimraf outdir when clean is true', async () => {186 const entryPoints = ['func1/index.ts', 'func2/index.ts'];187 const outdir = 'someOutdir';188 const config: BuilderConfigType = {189 project: projectDir,190 entryPoints,191 clean: true,192 esbuildOptions: {193 outdir,194 },195 };196 parseConfigStub.returns(config);197 await build(config);198 expect(rimrafStub.calledOnce).to.be.true;199 expect(rimrafStub.firstCall.args[0]).to.eql(outdir);200 });201 it('should fix outdir when only one entry point is found', async () => {202 const outdir = 'some/outdir';203 const config: BuilderConfigType = {204 project: projectDir,205 exclude: ['dir1'],206 esbuildOptions: {207 outdir,208 },209 };210 const files = [`${process.cwd()}/${projectDir}/func1/index.ts`];211 globStub.resolves(files);212 parseConfigStub.returns(config);213 await build(config);214 expect(rimrafStub.called).to.be.false;215 expect(shimPluginStub.called).to.be.false;216 expect(esbuildStub.calledOnce).to.be.true;217 expect(esbuildStub.firstCall.args[0]).to.eql({218 ...expectedDefaultConfig,219 ...config.esbuildOptions,220 entryPoints: files,221 outdir: path.join(outdir, path.basename(path.dirname(files[0]))),222 plugins: [],223 });224 });225 it('should add shim plugin with dirname shim when advancedOptions.enableDirnameShim is true', async () => {226 const entryPoints = ['func1/index.ts', 'func2/index.ts'];227 const config: BuilderConfigType = {228 project: projectDir,229 entryPoints,230 esbuildOptions: {231 outdir: 'something',232 },233 advancedOptions: {234 enableDirnameShim: true,235 },236 };237 parseConfigStub.returns(config);238 await build(config);239 expect(globStub.called).to.be.false;240 expect(rimrafStub.called).to.be.false;241 expect(shimPluginStub.calledOnce).to.be.true;242 expect(shimPluginStub.firstCall.args[0]).to.eql({ shims: [shims.DIRNAME_SHIM] });243 expect(esbuildStub.calledOnce).to.be.true;244 expect(esbuildStub.firstCall.args[0]).to.eql({245 ...expectedDefaultConfig,246 ...config.esbuildOptions,247 entryPoints: entryPoints.map(entryPoint => `${process.cwd()}/${projectDir}/${entryPoint}`),248 plugins: ['shimPluginStub'],249 });250 });251 it('should add shim plugin with require shim when advancedOptions.enableRequireShim is true', async () => {252 const entryPoints = ['func1/index.ts', 'func2/index.ts'];253 const config: BuilderConfigType = {254 project: projectDir,255 entryPoints,256 esbuildOptions: {257 outdir: 'something',258 },259 advancedOptions: {260 enableRequireShim: true,261 },262 };263 parseConfigStub.returns(config);264 await build(config);265 expect(globStub.called).to.be.false;266 expect(rimrafStub.called).to.be.false;267 expect(shimPluginStub.calledOnce).to.be.true;268 expect(shimPluginStub.firstCall.args[0]).to.eql({ shims: [shims.REQUIRE_SHIM] });269 expect(esbuildStub.calledOnce).to.be.true;270 expect(esbuildStub.firstCall.args[0]).to.eql({271 ...expectedDefaultConfig,272 ...config.esbuildOptions,273 entryPoints: entryPoints.map(entryPoint => `${process.cwd()}/${projectDir}/${entryPoint}`),274 plugins: ['shimPluginStub'],275 });276 });277 it('should write output files', async () => {278 const entryPoints = ['func1/index.ts', 'func2/index.ts'];279 esbuildStub.resolves({280 outputFiles: [281 { path: 'some/dir/file1', text: 'content1' },282 { path: 'some/dir/file2', text: 'content2' },283 ],284 });285 const config: BuilderConfigType = {286 project: projectDir,287 entryPoints,288 esbuildOptions: {289 outdir: 'something',290 },291 };292 parseConfigStub.returns(config);293 await build(config);294 const output1 = await fs.readFile('some/dir/file1', 'utf8');295 const output2 = await fs.readFile('some/dir/file2', 'utf8');296 expect(output1).to.eql('content1');297 expect(output2).to.eql('content2');298 });299 it('should throw NoEntryPointsError when there are no entry points', async () => {300 const config: BuilderConfigType = {301 project: projectDir,302 exclude: ['dir1'],303 esbuildOptions: {304 outdir: 'something',305 },306 };307 globStub.resolves([]);308 parseConfigStub.returns(config);309 return expect(build(config)).to.eventually.be.rejectedWith(NoEntryPointsError);310 });311 it('should throw ProjectDirectoryNotFoundError when project dir is invalid', async () => {312 const config: BuilderConfigType = {313 project: 'some/dir',314 entryPoints: ['func1/index.ts'],315 };316 parseConfigStub.returns(config);317 return expect(build(config)).to.eventually.be.rejectedWith(ProjectDirectoryNotFoundError);318 });319 it('should throw InvalidConfigFileError when parseConfig throws', async () => {320 parseConfigStub.throws(new InvalidConfigError(new ZodError([])));321 return expect(build({} as any)).to.eventually.be.rejectedWith(InvalidConfigError);322 });323 });324 describe('watch', () => {325 it('should parse config', async () => {326 const config: WatchConfigType = {327 project: projectDir,328 entryPoints: ['func/index.ts'],329 clean: true,330 };331 parseConfigStub.returns(config);332 await watch(config);333 expect(parseConfigStub.calledOnce).to.be.true;334 expect(parseConfigStub.firstCall.args[0]).to.eql(config);335 });336 it('should call esbuild.build with correct config when entryPoints were supplied', async () => {337 const entryPoints = ['func1/index.ts', 'func2/index.ts'];338 const config: WatchConfigType = {339 project: projectDir,340 entryPoints,341 };342 parseConfigStub.returns(config);343 await watch(config);344 expect(globStub.called).to.be.false;345 expect(rimrafStub.called).to.be.false;346 expect(shimPluginStub.called).to.be.false;347 expect(esbuildStub.calledOnce).to.be.true;348 expect(esbuildStub.firstCall.args[0])349 .excluding('watch')350 .to.eql({351 ...expectedDefaultConfig,352 entryPoints: entryPoints.map(entryPoint => `${process.cwd()}/${projectDir}/${entryPoint}`),353 plugins: [],354 });355 expect(typeof esbuildStub.firstCall.args[0].watch.onRebuild).to.eql('function');356 });357 it('should call esbuild.build with correct config when esbuildOptions were supplied', async () => {358 const entryPoints = ['func1/index.ts', 'func2/index.ts'];359 const config: WatchConfigType = {360 project: projectDir,361 entryPoints,362 esbuildOptions: {363 outdir: 'something',364 },365 };366 parseConfigStub.returns(config);367 await watch(config);368 expect(globStub.called).to.be.false;369 expect(rimrafStub.called).to.be.false;370 expect(shimPluginStub.called).to.be.false;371 expect(esbuildStub.calledOnce).to.be.true;372 expect(esbuildStub.firstCall.args[0])373 .excluding('watch')374 .to.eql({375 ...expectedDefaultConfig,376 ...config.esbuildOptions,377 entryPoints: entryPoints.map(entryPoint => `${process.cwd()}/${projectDir}/${entryPoint}`),378 plugins: [],379 });380 expect(typeof esbuildStub.firstCall.args[0].watch.onRebuild).to.eql('function');381 });382 it('should glob all index.ts files when no entryPoints were supplied', async () => {383 const config: WatchConfigType = {384 project: projectDir,385 esbuildOptions: {386 outdir: 'something',387 },388 };389 const files = [`${process.cwd()}/${projectDir}/func1/index.ts`, `${process.cwd()}/${projectDir}/func2/index.ts`];390 globStub.resolves(files);391 parseConfigStub.returns(config);392 await watch(config);393 expect(rimrafStub.called).to.be.false;394 expect(shimPluginStub.called).to.be.false;395 expect(esbuildStub.calledOnce).to.be.true;396 expect(esbuildStub.firstCall.args[0])397 .excluding('watch')398 .to.eql({399 ...expectedDefaultConfig,400 ...config.esbuildOptions,401 entryPoints: files,402 plugins: [],403 });404 expect(typeof esbuildStub.firstCall.args[0].watch.onRebuild).to.eql('function');405 expect(globStub.calledOnce).to.be.true;406 expect(globStub.firstCall.args).to.eql([407 '**/index.ts',408 {409 cwd: projectDir,410 absolute: true,411 ignore: ['**/node_modules/**'],412 },413 ]);414 });415 it('should glob all index.ts files when no entryPoints but excludes were supplied', async () => {416 const config: WatchConfigType = {417 project: projectDir,418 exclude: ['dir1'],419 esbuildOptions: {420 outdir: 'something',421 },422 };423 const files = [`${process.cwd()}/${projectDir}/func1/index.ts`, `${process.cwd()}/${projectDir}/func2/index.ts`];424 globStub.resolves(files);425 parseConfigStub.returns(config);426 await watch(config);427 expect(rimrafStub.called).to.be.false;428 expect(shimPluginStub.called).to.be.false;429 expect(esbuildStub.calledOnce).to.be.true;430 expect(esbuildStub.firstCall.args[0])431 .excluding('watch')432 .to.eql({433 ...expectedDefaultConfig,434 ...config.esbuildOptions,435 entryPoints: files,436 plugins: [],437 });438 expect(typeof esbuildStub.firstCall.args[0].watch.onRebuild).to.eql('function');439 expect(globStub.calledOnce).to.be.true;440 expect(globStub.firstCall.args).to.eql([441 '**/index.ts',442 {443 cwd: projectDir,444 absolute: true,445 ignore: ['**/node_modules/**', ...config.exclude!],446 },447 ]);448 });449 it('should rimraf outdir when clean is true', async () => {450 const entryPoints = ['func1/index.ts', 'func2/index.ts'];451 const outdir = 'someOutdir';452 const config: WatchConfigType = {453 project: projectDir,454 entryPoints,455 clean: true,456 esbuildOptions: {457 outdir,458 },459 };460 parseConfigStub.returns(config);461 await watch(config);462 expect(rimrafStub.calledOnce).to.be.true;463 expect(rimrafStub.firstCall.args[0]).to.eql(outdir);464 });465 it('should fix outdir when only one entry point is found', async () => {466 const outdir = 'some/outdir';467 const config: WatchConfigType = {468 project: projectDir,469 exclude: ['dir1'],470 esbuildOptions: {471 outdir,472 },473 };474 const files = [`${process.cwd()}/${projectDir}/func1/index.ts`];475 globStub.resolves(files);476 parseConfigStub.returns(config);477 await watch(config);478 expect(rimrafStub.called).to.be.false;479 expect(shimPluginStub.called).to.be.false;480 expect(esbuildStub.calledOnce).to.be.true;481 expect(esbuildStub.firstCall.args[0])482 .excluding('watch')483 .to.eql({484 ...expectedDefaultConfig,485 ...config.esbuildOptions,486 entryPoints: files,487 outdir: path.join(outdir, path.basename(path.dirname(files[0]))),488 plugins: [],489 });490 expect(typeof esbuildStub.firstCall.args[0].watch.onRebuild).to.eql('function');491 });492 it('should add dirname plugin when advancedOptions.enableDirnameShim is true', async () => {493 const entryPoints = ['func1/index.ts', 'func2/index.ts'];494 const config: WatchConfigType = {495 project: projectDir,496 entryPoints,497 esbuildOptions: {498 outdir: 'something',499 },500 advancedOptions: {501 enableDirnameShim: true,502 },503 };504 parseConfigStub.returns(config);505 await watch(config);506 expect(globStub.called).to.be.false;507 expect(rimrafStub.called).to.be.false;508 expect(shimPluginStub.calledOnce).to.be.true;509 expect(shimPluginStub.firstCall.args[0]).to.eql({ shims: [shims.DIRNAME_SHIM] });510 expect(esbuildStub.calledOnce).to.be.true;511 expect(esbuildStub.firstCall.args[0])512 .excluding(['watch'])513 .to.eql({514 ...expectedDefaultConfig,515 ...config.esbuildOptions,516 entryPoints: entryPoints.map(entryPoint => `${process.cwd()}/${projectDir}/${entryPoint}`),517 plugins: ['shimPluginStub'],518 });519 expect(typeof esbuildStub.firstCall.args[0].watch.onRebuild).to.eql('function');520 });521 it('should add require plugin when advancedOptions.enableRequireShim is true', async () => {522 const entryPoints = ['func1/index.ts', 'func2/index.ts'];523 const config: WatchConfigType = {524 project: projectDir,525 entryPoints,526 esbuildOptions: {527 outdir: 'something',528 },529 advancedOptions: {530 enableRequireShim: true,531 },532 };533 parseConfigStub.returns(config);534 await watch(config);535 expect(globStub.called).to.be.false;536 expect(rimrafStub.called).to.be.false;537 expect(shimPluginStub.calledOnce).to.be.true;538 expect(shimPluginStub.firstCall.args[0]).to.eql({ shims: [shims.REQUIRE_SHIM] });539 expect(esbuildStub.calledOnce).to.be.true;540 expect(esbuildStub.firstCall.args[0])541 .excluding(['watch'])542 .to.eql({543 ...expectedDefaultConfig,544 ...config.esbuildOptions,545 entryPoints: entryPoints.map(entryPoint => `${process.cwd()}/${projectDir}/${entryPoint}`),546 plugins: ['shimPluginStub'],547 });548 expect(typeof esbuildStub.firstCall.args[0].watch.onRebuild).to.eql('function');549 });550 it('should call logger.error when onRebuild gets called with error', async () => {551 const entryPoints = ['func1/index.ts', 'func2/index.ts'];552 const config: WatchConfigType = {553 project: projectDir,554 entryPoints,555 };556 parseConfigStub.returns(config);557 await watch(config);558 mockLogger.verbose.resetHistory();559 mockLogger.info.resetHistory();560 mockLogger.warn.resetHistory();561 mockLogger.error.resetHistory();562 await esbuildStub.firstCall.args[0].watch.onRebuild({});563 expect(mockLogger.verbose.called).to.be.false;564 expect(mockLogger.info.called).to.be.false;565 expect(mockLogger.warn.called).to.be.false;566 expect(mockLogger.error.calledOnce).to.be.true;567 });568 it('should call logger.info when onRebuild gets called without error', async () => {569 const entryPoints = ['func1/index.ts', 'func2/index.ts'];570 const config: WatchConfigType = {571 project: projectDir,572 entryPoints,573 };574 parseConfigStub.returns(config);575 await watch(config);576 mockLogger.verbose.resetHistory();577 mockLogger.info.resetHistory();578 mockLogger.warn.resetHistory();579 mockLogger.error.resetHistory();580 await esbuildStub.firstCall.args[0].watch.onRebuild();581 expect(mockLogger.verbose.called).to.be.false;582 expect(mockLogger.warn.called).to.be.false;583 expect(mockLogger.error.called).to.be.false;584 expect(mockLogger.info.calledOnce).to.be.true;585 });586 it('should write output files', async () => {587 const entryPoints = ['func1/index.ts', 'func2/index.ts'];588 const config: WatchConfigType = {589 project: projectDir,590 entryPoints,591 };592 parseConfigStub.returns(config);593 await watch(config);594 await esbuildStub.firstCall.args[0].watch.onRebuild(undefined, {595 outputFiles: [596 { path: 'some/dir/file1', text: 'content1' },597 { path: 'some/dir/file2', text: 'content2' },598 ],599 });600 const output1 = await fs.readFile('some/dir/file1', 'utf8');601 const output2 = await fs.readFile('some/dir/file2', 'utf8');602 expect(output1).to.eql('content1');603 expect(output2).to.eql('content2');604 });605 it('should call options.onRebuild when supplied', async () => {606 const entryPoints = ['func1/index.ts', 'func2/index.ts'];607 const onRebuildCallback = sinon.spy();608 const config: WatchConfigType = {609 project: projectDir,610 entryPoints,611 onRebuild: onRebuildCallback,612 };613 parseConfigStub.returns(config);614 await watch(config);615 await esbuildStub.firstCall.args[0].watch.onRebuild(undefined, {616 outputFiles: [617 { path: 'some/dir/file1', text: 'content1' },618 { path: 'some/dir/file2', text: 'content2' },619 ],620 });621 expect(onRebuildCallback.calledOnce).to.be.true;622 });623 it('should throw NoEntryPointsError when there are no entry points', async () => {624 const config: WatchConfigType = {625 project: projectDir,626 exclude: ['dir1'],627 esbuildOptions: {628 outdir: 'something',629 },630 };631 globStub.resolves([]);632 parseConfigStub.returns(config);633 return expect(watch(config)).to.eventually.be.rejectedWith(NoEntryPointsError);634 });635 it('should throw ProjectDirectoryNotFoundError when project dir is invalid', async () => {636 const config: WatchConfigType = {637 project: 'some/dir',638 entryPoints: ['func1/index.ts'],639 };640 parseConfigStub.returns(config);641 return expect(watch(config)).to.eventually.be.rejectedWith(ProjectDirectoryNotFoundError);642 });643 it('should throw InvalidConfigFileError when parseConfig throws', async () => {644 parseConfigStub.throws(new InvalidConfigError(new ZodError([])));645 return expect(watch({} as any)).to.eventually.be.rejectedWith(InvalidConfigError);646 });647 });...

Full Screen

Full Screen

handler.spec.ts

Source:handler.spec.ts Github

copy

Full Screen

1import * as mockfs from 'mock-fs'2import * as sinon from 'sinon'3import { PackageFile, AriaConfigOptions } from 'aria-build'4import { expect } from 'aria-mocha'5import { handler } from './handler'6import { ServeCommandLineOptions } from './options'7describe('handler', () => {8 let libs: typeof import('./libs')9 let hmrBuild: typeof import('./hmr-build')10 function createStubs() {11 const parsePluginsStub = sinon.spy(libs, 'parsePlugins')12 const fsCleanStub = sinon.stub(libs, 'clean').returns(void 0)13 const parseConfigStub = sinon.spy(libs, 'parseConfig')14 const pkg: PackageFile = {15 name: 'aria-test',16 dependencies: {17 'vue': '2.0.1'18 }19 }20 const getPackage = sinon21 .stub(libs, 'getPackage')22 .returns(Promise.resolve(pkg))23 const sirvCliStub = sinon.stub(libs, 'sirvCli').returns(void 0)24 const hmrBuildStub = sinon.stub(hmrBuild, 'hmrBuild').returns(void 0)25 return {26 parsePluginsStub,27 fsCleanStub,28 parseConfigStub,29 getPackage,30 sirvCliStub,31 hmrBuildStub32 }33 }34 before(async () => {35 [ hmrBuild, libs ] = await Promise.all([ import('./hmr-build'), import('./libs') ])36 })37 afterEach(() => {38 mockfs.restore()39 sinon.restore()40 })41 it('should build with handler with default options', async() => {42 const options: ServeCommandLineOptions = {43 port: 3000,44 dir: 'public',45 sourcemap: true,46 hmr: false47 }48 const config: AriaConfigOptions = { 49 output: {50 globals: {}51 }52 }53 const getAriaConfigStub = sinon54 .stub(libs, 'getAriaConfig')55 .returns(Promise.resolve(config))56 const {57 parsePluginsStub,58 fsCleanStub,59 parseConfigStub,60 getPackage,61 sirvCliStub,62 hmrBuildStub63 } = createStubs()64 await handler(options)65 expect(parsePluginsStub.called).toBeTrue()66 expect(fsCleanStub.called).toBeTrue()67 expect(parseConfigStub.called).toBeTrue()68 expect(getPackage.called).toBeTrue()69 expect(sirvCliStub.called).toBeTrue()70 expect(hmrBuildStub.called).toBeTrue()71 expect(getAriaConfigStub.called).toBeTrue()72 })73 it('should build with handler with custom options', async() => {74 const options: ServeCommandLineOptions = {75 port: 3000,76 dir: 'public',77 sourcemap: false,78 hmr: false,79 clean: 'dist'80 }81 const config: AriaConfigOptions = { 82 output: {83 globals: {}84 }85 }86 const getAriaConfigStub = sinon87 .stub(libs, 'getAriaConfig')88 .returns(Promise.resolve(config))89 const {90 parsePluginsStub,91 fsCleanStub,92 parseConfigStub,93 getPackage,94 sirvCliStub,95 hmrBuildStub96 } = createStubs()97 await handler(options)98 99 expect(parsePluginsStub.called).toBeTrue()100 expect(fsCleanStub.called).toBeTrue()101 expect(parseConfigStub.called).toBeTrue()102 expect(getPackage.called).toBeTrue()103 expect(sirvCliStub.called).toBeTrue()104 expect(hmrBuildStub.called).toBeTrue()105 expect(getAriaConfigStub.called).toBeTrue()106 })...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = require('stryker-parent');2var config = strykerParent.parseConfigStub('./stryker.conf.js');3var strykerParent = require('stryker-parent');4var config = strykerParent.parseConfigStub('./stryker.conf.js');5var strykerParent = require('stryker-parent');6var config = strykerParent.parseConfigStub('./stryker.conf.js');7var strykerParent = require('stryker-parent');8var config = strykerParent.parseConfigStub('./stryker.conf.js');9var strykerParent = require('stryker-parent');10var config = strykerParent.parseConfigStub('./stryker.conf.js');11var strykerParent = require('stryker-parent');12var config = strykerParent.parseConfigStub('./stryker.conf.js');13var strykerParent = require('stryker-parent');14var config = strykerParent.parseConfigStub('./stryker.conf.js');15var strykerParent = require('stryker-parent');16var config = strykerParent.parseConfigStub('./stryker.conf.js');17var strykerParent = require('stryker-parent');18var config = strykerParent.parseConfigStub('./stryker.conf.js');19var strykerParent = require('stryker-parent');20var config = strykerParent.parseConfigStub('./stryker.conf.js');21var strykerParent = require('stryker-parent');22var config = strykerParent.parseConfigStub('./stryker.conf.js');23var strykerParent = require('stryker-parent');24var config = strykerParent.parseConfigStub('./stryker.conf.js');

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = {2 parseConfigStub: function(config) {3 return config;4 }5};6{7 "scripts": {8 },9}10module.exports = {11 parseConfig: function(config) {12 return config;13 }14};15{16 "scripts": {17 },18}19module.exports = {20 parseConfig: function(config) {21 return config;22 }23};24{25 "scripts": {26 },27}28{29 "scripts": {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { parseConfigStub } = require('stryker-parent');2const config = parseConfigStub();3module.exports = function(config) {4 config.set({5 });6};

Full Screen

Using AI Code Generation

copy

Full Screen

1const { parseConfigStub } = require('stryker-parent');2const config = parseConfigStub(__dirname, 'stryker.conf.js');3module.exports = function (config) {4 config.set({5 });6};

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stryker-parent automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful