How to use the worker-farm.mock function in worker-farm

To help you get started, we’ve selected a few worker-farm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github trivago / parallel-webpack / __tests__ / index.spec.js View on Github external
it('should call generate workers and return farm promise', () => {
            jest.spyOn(console, 'log').mockImplementation(() => {});
            promisify.mockReturnValueOnce(jest.fn());

            const returnPromise = run('testConfig.js', { colors: false }, jest.fn());
            expect(workerFarm.mock.calls[0][0]).toEqual({ maxRetries: 0 });

            expect(returnPromise).toBe(Bluebird);
            expect(promisify).toHaveBeenCalledTimes(1);
            expect(error).toHaveBeenCalledTimes(1);
            expect(then).toHaveBeenCalledTimes(2);
            expect(Bluebird.finally).toHaveBeenCalledTimes(1);
            expect(asCallback).toHaveBeenCalledTimes(1);
        });

worker-farm

Distribute processing tasks to child processes with an über-simple API and baked-in durability & custom concurrency options.

MIT
Latest version published 6 years ago

Package Health Score

74 / 100
Full package analysis