Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
before(() => {
logLevel = log.getLevel();
log.setLevel(log.LEVELS.ERROR);
});
beforeEach(() => {
log.setLevel(log.LEVELS.OFF);
pool = new Apify.PuppeteerPool({
launchPuppeteerOptions: {
headless: true,
},
});
});
afterEach(async () => {
before(() => {
prevEnvHeadless = process.env[ENV_VARS.HEADLESS];
process.env[ENV_VARS.HEADLESS] = '1';
logLevel = log.getLevel();
log.setLevel(log.LEVELS.ERROR);
});
before(() => {
logLevel = log.getLevel();
log.setLevel(log.LEVELS.ERROR);
prevEnvHeadless = process.env[ENV_VARS.HEADLESS];
process.env[ENV_VARS.HEADLESS] = '1';
});
before(() => {
logLevel = log.getLevel();
log.setLevel(log.LEVELS.ERROR);
});
const sources = [
{ url: 'https://www.example.com' },
{ url: 'https://www.example.com' },
{ url: 'https://www.example.com' },
{ url: 'https://www.ex2mple.com' },
];
let requestList = new Apify.RequestList({
sources,
keepDuplicateUrls: true,
});
await requestList.initialize();
expect(requestList.length()).to.be.eql(4);
log.setLevel(log.LEVELS.INFO);
const logStub = sinon.stub(console, 'log');
requestList = new Apify.RequestList({
sources: sources.concat([
{ url: 'https://www.example.com', uniqueKey: '123' },
{ url: 'https://www.example.com', uniqueKey: '123' },
{ url: 'https://www.example.com', uniqueKey: '456' },
{ url: 'https://www.ex2mple.com', uniqueKey: '456' },
]),
keepDuplicateUrls: true,
});
await requestList.initialize();
expect(requestList.length()).to.be.eql(6);
expect(logStub.called).to.be.eql(true);
expect(logStub.getCall(0).args[0]).to.include('Check your sources\' unique keys.');
before(() => {
logLevel = log.getLevel();
log.setLevel(log.LEVELS.ERROR);
});
before(() => {
originalLevel = log.getLevel();
log.setLevel(log.LEVELS.OFF);
});
before(() => {
logLevel = log.getLevel();
log.setLevel(log.LEVELS.ERROR);
process.env[ENV_VARS.IS_AT_HOME] = 1;
});
before(() => {
logLevel = log.getLevel();
log.setLevel(log.LEVELS.ERROR);
});