Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

Upgraded Puppeteer to 1.8.0, upgraded NPM deps, fixed lint errors, other minor fixes

Jan Curn107714b2d687
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4e0feea8d..7b2cca34c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+xxx
+==================
+- Upgraded Puppeteer to 1.8.0
+- Upgraded NPM dependencies, fixed lint errors
+
0.7.0 / 2018-09-11
==================
- Updated `DEFAULT_USER_AGENT` and `USER_AGENT_LIST`
diff --git a/README.md b/README.md
index c8e28b895..b2e14ad22 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,7 @@
* [Usage on the Apify cloud platform](#usage-on-the-apify-cloud-platform)
- [What is the "actor"?](#what-is-the-actor)
- [Examples](#examples)
- * [Load a few pages in raw HTML](#load-a-few-pages-in-raw-html)
+ * [Crawl several pages in raw HTML](#crawl-several-pages-in-raw-html)
* [Crawl an external list of URLs with Cheerio](#crawl-an-external-list-of-urls-with-cheerio)
* [Recursively crawl a website using Puppeteer](#recursively-crawl-a-website-using-puppeteer)
* [Save page screenshots](#save-page-screenshots)
diff --git a/package.json b/package.json
index 9df048bf1..b677e0462 100644
--- a/package.json
+++ b/package.json
@@ -49,7 +49,7 @@
},
"dependencies": {
"apify-shared": "0.0.55",
- "apify-client": "^0.2.13",
+ "apify-client": "^0.3.0",
"bluebird": "^3.5.0",
"cheerio": "^1.0.0-rc.2",
"content-type": "^1.0.3",
@@ -72,28 +72,28 @@
"basic-auth-parser": "^0.0.2",
"chai": "^4.0.2",
"chai-as-promised": "^7.1.1",
- "eslint": "^4.11.0",
- "eslint-config-airbnb": "^16.1.0",
- "eslint-config-airbnb-base": "^12.1.0",
+ "eslint": "^5.5.0",
+ "eslint-config-airbnb": "^17.1.0",
+ "eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
- "eslint-plugin-promise": "^3.4.2",
+ "eslint-plugin-promise": "^4.0.1",
"eslint-plugin-react": "^7.0.1",
"jsdoc": "^3.4.3",
"jsdoc-export-default-interop": "^0.3.1",
"markdown-toc": "^1.2.0",
"mocha": "^3.5.3",
- "nyc": "^11.7.1",
+ "nyc": "^13.0.1",
"portastic": "^1.0.1",
"proxy": "^0.2.4",
"request": "^2.81.0",
- "sinon": "^4.1.2",
+ "sinon": "^6.3.1",
"sinon-stub-promise": "^4.0.0",
"tmp": "^0.0.33",
"why-is-node-running": "^2.0.2"
},
"optionalDependencies": {
- "puppeteer": "^1.7.0",
+ "puppeteer": "^1.8.0",
"selenium-webdriver": "^3.6.0"
}
}
diff --git a/src/actor.js b/src/actor.js
index 2806c77d4..f8a5884f2 100644
--- a/src/actor.js
+++ b/src/actor.js
@@ -3,7 +3,8 @@ import Promise from 'bluebird';
import log from 'apify-shared/log';
import { checkParamOrThrow } from 'apify-client/build/utils';
import { APIFY_PROXY_VALUE_REGEX } from 'apify-shared/regexs';
-import { ENV_VARS, LOCAL_ENV_VARS, EXIT_CODES, ACT_TASK_TERMINAL_STATUSES, ACT_TASK_STATUSES } from './constants';
+import { ENV_VARS, LOCAL_ENV_VARS, ACT_TASK_TERMINAL_STATUSES, ACT_TASK_STATUSES } from 'apify-shared/consts';
+import { EXIT_CODES } from './constants';
import { initializeEvents, stopEvents } from './events';
import { newPromise, apifyClient, addCharsetToContentType } from './utils';
import { maybeStringify } from './key_value_store';
@@ -153,6 +154,10 @@ export const main = (userFunc) => {
throw new Error('Handler function must be provided as a parameter');
}
+ if (!process.env[ENV_VARS.LOCAL_STORAGE_DIR] && !process.env[ENV_VARS.TOKEN]) {
+ throw new Error(`Neither ${ENV_VARS.LOCAL_STORAGE_DIR} nor ${ENV_VARS.TOKEN} environment variable is set. You need to set one these variables in order to enable data storage.`); // eslint-disable-line max-len
+ }
+
// This is to enable unit tests where process.exit() is mocked and doesn't really exit the process
// Note that mocked process.exit() might throw, so set exited flag before calling it to avoid confusion.
let exited = false;
diff --git a/src/autoscaled_pool.js b/src/autoscaled_pool.js
index 574078e0f..c4206746c 100644
--- a/src/autoscaled_pool.js
+++ b/src/autoscaled_pool.js
@@ -1,10 +1,10 @@
import Promise from 'bluebird';
import log from 'apify-shared/log';
+import { ACTOR_EVENT_NAMES } from 'apify-shared/consts';
import _ from 'underscore';
import { checkParamOrThrow } from 'apify-client/build/utils';
import { getMemoryInfo, isPromise, avg, isAtHome } from './utils';
import events from './events';
-import { ACTOR_EVENT_NAMES } from './constants';
// NOTE: If this is too low, getMemoryInfo() has so much overheads that it chokes the system
const AUTOSCALE_INTERVAL_MILLIS = 1000;
@@ -375,6 +375,7 @@ export default class AutoscaledPool {
return hasSpaceForInstances;
}
+
/**
* If number of running task is lower than allowed concurrency and this.isTaskReadyFunction()
* returns true then starts a new task.
diff --git a/src/constants.js b/src/constants.js
index 91c0440f6..96c6ab311 100644
--- a/src/constants.js
+++ b/src/constants.js
@@ -1,34 +1,33 @@
-import * as consts from 'apify-shared/consts';
+import { ACTOR_EVENT_NAMES } from 'apify-shared/consts';
/**
* The default user agent used by `Apify.launchPuppeteer`.
* Last updated on 2018-09-10.
*/
-consts.DEFAULT_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'; // eslint-disable-line max-len
+export const DEFAULT_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'; // eslint-disable-line max-len
/**
* Exit codes for the actor process.
* The error codes must be in range 1-128, to avoid collision with signal exits
* and to ensure Docker will handle them correctly!
*/
-consts.EXIT_CODES = {
+export const EXIT_CODES = {
SUCCESS: 0,
ERROR_USER_FUNCTION_THREW: 91,
ERROR_UNKNOWN: 92,
};
/**
- * These events are just internal for Apify package so we don't need them
- * in apify-shared package.
+ * These events are just internal for Apify package so we don't need them in apify-shared package.
*/
-consts.ACTOR_EVENT_NAMES.PERSIST_STATE = 'persistState';
+export const ACTOR_EVENT_NAMES_EX = Object.assign({}, ACTOR_EVENT_NAMES, { PERSIST_STATE: 'persistState' });
/**
* Most common user agents from https://techblog.willshouse.com/2012/01/03/most-common-user-agents/
*
* Last updated on 2018-09-10.
*/
-consts.USER_AGENT_LIST = [
+export const USER_AGENT_LIST = [
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36',
'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36',
@@ -115,5 +114,3 @@ consts.USER_AGENT_LIST = [
'Mozilla/5.0 (X11; CrOS x86_64 10575.58.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36',
'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0',
];
-
-module.exports = consts;
diff --git a/src/dataset.js b/src/dataset.js
index a300a22ae..0e7811bef 100644
--- a/src/dataset.js
+++ b/src/dataset.js
@@ -6,7 +6,7 @@ import Promise from 'bluebird';
import { leftpad } from 'apify-shared/utilities';
import LruCache from 'apify-shared/lru_cache';
import { checkParamOrThrow } from 'apify-client/build/utils';
-import { ENV_VARS, LOCAL_STORAGE_SUBDIRS, MAX_PAYLOAD_SIZE_BYTES } from './constants';
+import { ENV_VARS, LOCAL_STORAGE_SUBDIRS, MAX_PAYLOAD_SIZE_BYTES } from 'apify-shared/consts';
import { apifyClient, ensureDirExists, openRemoteStorage, openLocalStorage, ensureTokenOrLocalStorageEnvExists } from './utils';
export const LOCAL_STORAGE_SUBDIR = LOCAL_STORAGE_SUBDIRS.datasets;
diff --git a/src/events.js b/src/events.js
index afc59aa1f..3bfa9657d 100644
--- a/src/events.js
+++ b/src/events.js
@@ -1,7 +1,8 @@
import EventEmitter from 'events';
import WebSocket from 'ws';
import log from 'apify-shared/log';
-import { ENV_VARS, ACTOR_EVENT_NAMES } from './constants';
+import { ENV_VARS, ACTOR_EVENT_NAMES } from 'apify-shared/consts';
+import { ACTOR_EVENT_NAMES_EX } from './constants';
const PERSIST_STATE_INTERVAL_MILLIS = 60 * 1000;
@@ -94,7 +95,7 @@ export default events;
* @ignore
*/
const emitPersistStateEvent = (isMigrating = false) => {
- events.emit(ACTOR_EVENT_NAMES.PERSIST_STATE, { isMigrating });
+ events.emit(ACTOR_EVENT_NAMES_EX.PERSIST_STATE, { isMigrating });
};
/**
diff --git a/src/index.js b/src/index.js
index 2a68d8277..bf33de0f2 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,5 +1,5 @@
import log from 'apify-shared/log';
-import { ENV_VARS } from './constants';
+import { ENV_VARS } from 'apify-shared/consts';
import { main, getEnv, call, getApifyProxyUrl } from './actor';
import AutoscaledPool from './autoscaled_pool';
import BasicCrawler from './basic_crawler';
diff --git a/src/key_value_store.js b/src/key_value_store.js
index a7dc663da..0f0e1635a 100644
--- a/src/key_value_store.js
+++ b/src/key_value_store.js
@@ -6,8 +6,8 @@ import contentTypeParser from 'content-type';
import LruCache from 'apify-shared/lru_cache';
import mime from 'mime';
import { KEY_VALUE_STORE_KEY_REGEX } from 'apify-shared/regexs';
+import { ENV_VARS, LOCAL_STORAGE_SUBDIRS } from 'apify-shared/consts';
import { checkParamOrThrow, parseBody } from 'apify-client/build/utils';
-import { ENV_VARS, LOCAL_STORAGE_SUBDIRS } from './constants';
import {
addCharsetToContentType, apifyClient, ensureDirExists, openRemoteStorage, openLocalStorage, ensureTokenOrLocalStorageEnvExists,
} from './utils';
@@ -58,8 +58,8 @@ const validateSetValueParams = (key, value, options) => {
if (!key) throw new Error('The "key" parameter cannot be empty');
if (!KEY_VALUE_STORE_KEY_REGEX.test(key)) {
- throw new Error('The "key" parameter may contain only the following characters: ' +
- "[a-zA-Z0-9!-_.'()");
+ throw new Error('The "key" parameter may contain only the following characters: '
+ + "[a-zA-Z0-9!-_.'()");
}
};
diff --git a/src/puppeteer.js b/src/puppeteer.js
index 2da1a34d9..8744e5ee9 100644
--- a/src/puppeteer.js
+++ b/src/puppeteer.js
@@ -2,7 +2,8 @@ import _ from 'underscore';
import { checkParamOrThrow } from 'apify-client/build/utils';
import { anonymizeProxy, closeAnonymizedProxy, redactUrl } from 'proxy-chain';
import log from 'apify-shared/log';
-import { ENV_VARS, DEFAULT_USER_AGENT } from './constants';
+import { ENV_VARS } from 'apify-shared/consts';
+import { DEFAULT_USER_AGENT } from './constants';
import { newPromise, getTypicalChromeExecutablePath } from './utils';
import { getApifyProxyUrl } from './actor';
import { registerBrowserForLiveView } from './puppeteer_live_view_server';
diff --git a/src/puppeteer_live_view_server.js b/src/puppeteer_live_view_server.js
index 6bbd485c6..f904a4186 100644
--- a/src/puppeteer_live_view_server.js
+++ b/src/puppeteer_live_view_server.js
@@ -4,9 +4,9 @@ import Promise from 'bluebird';
import WebSocket from 'ws';
import log from 'apify-shared/log';
import { promisifyServerListen } from 'apify-shared/utilities';
+import { ENV_VARS } from 'apify-shared/consts';
import { checkParamOrThrow } from 'apify-client/build/utils';
import { layout, indexPage, detailPage, errorPage } from './puppeteer_live_view_client';
-import { ENV_VARS } from './constants';
const DEFAULT_SCREENSHOT_TIMEOUT_MILLIS = 3000;
@@ -197,6 +197,7 @@ export class PuppeteerLiveViewBrowser extends EventEmitter {
})
.catch(err => log.error(err));
}
+
/**
* Handler invoked whenever a Browser is destroyed / disconnected in Puppeteer.
* @param {Browser} browser
diff --git a/src/request_list.js b/src/request_list.js
index c563c007c..12e5e303c 100644
--- a/src/request_list.js
+++ b/src/request_list.js
@@ -2,9 +2,9 @@ import { checkParamOrThrow } from 'apify-client/build/utils';
import log from 'apify-shared/log';
import _ from 'underscore';
import Promise from 'bluebird';
+import { ACTOR_EVENT_NAMES_EX } from './constants';
import Request from './request';
import events from './events';
-import { ACTOR_EVENT_NAMES } from './constants';
import { getFirstKey, publicUtils } from './utils';
import { getValue, setValue } from './key_value_store';
@@ -224,7 +224,7 @@ export default class RequestList {
if (!this.persistStateKey) return;
- events.on(ACTOR_EVENT_NAMES.PERSIST_STATE, () => {
+ events.on(ACTOR_EVENT_NAMES_EX.PERSIST_STATE, () => {
if (this.isStatePersisted) return;
return setValue(this.persistStateKey, this.getState())
diff --git a/src/request_queue.js b/src/request_queue.js
index c6915c25b..8d87a19bf 100644
--- a/src/request_queue.js
+++ b/src/request_queue.js
@@ -4,12 +4,12 @@ import path from 'path';
import { checkParamOrThrow } from 'apify-client/build/utils';
import LruCache from 'apify-shared/lru_cache';
import ListDictionary from 'apify-shared/list_dictionary';
+import { ENV_VARS, LOCAL_STORAGE_SUBDIRS } from 'apify-shared/consts';
import { delayPromise, checkParamPrototypeOrThrow } from 'apify-shared/utilities';
import Promise from 'bluebird';
import crypto from 'crypto';
import _ from 'underscore';
import Request from './request';
-import { ENV_VARS, LOCAL_STORAGE_SUBDIRS } from './constants';
import { ensureDirExists, apifyClient, openRemoteStorage, openLocalStorage, ensureTokenOrLocalStorageEnvExists } from './utils';
export const LOCAL_STORAGE_SUBDIR = LOCAL_STORAGE_SUBDIRS.requestQueues;
diff --git a/src/utils.js b/src/utils.js
index 854fa64ef..5e97c2f35 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -8,8 +8,9 @@ import psTree from '@apify/ps-tree';
import requestPromise from 'request-promise';
import XRegExp from 'xregexp';
import { delayPromise, getRandomInt } from 'apify-shared/utilities';
+import { ENV_VARS, LOCAL_ENV_VARS } from 'apify-shared/consts';
import { checkParamOrThrow } from 'apify-client/build/utils';
-import { ENV_VARS, LOCAL_ENV_VARS, USER_AGENT_LIST } from './constants';
+import { USER_AGENT_LIST } from './constants';
/* globals process */
@@ -434,8 +435,7 @@ export const openRemoteStorage = async (idOrName, defaultIdEnvVar, RemoteClass,
*/
export const ensureTokenOrLocalStorageEnvExists = (storageName) => {
if (!process.env[ENV_VARS.LOCAL_STORAGE_DIR] && !process.env[ENV_VARS.TOKEN]) {
- throw new Error(`Cannot use ${storageName} as neither ${ENV_VARS.LOCAL_STORAGE_DIR} nor ${ENV_VARS.TOKEN} environment variable is set. `
- + `Configure ${ENV_VARS.LOCAL_STORAGE_DIR} to enable storage in local directory or ${ENV_VARS.TOKEN} to use Apify cloud for storages.`);
+ throw new Error(`Cannot use ${storageName} as neither ${ENV_VARS.LOCAL_STORAGE_DIR} nor ${ENV_VARS.TOKEN} environment variable is set. You need to set one these variables in order to enable data storage.`); // eslint-disable-line max-len
}
};
diff --git a/src/webdriver.js b/src/webdriver.js
index eb048b981..1f1317dad 100644
--- a/src/webdriver.js
+++ b/src/webdriver.js
@@ -1,6 +1,7 @@
// import { ChromeLauncher } from 'lighthouse/lighthouse-cli/chrome-launcher';
import { anonymizeProxy, closeAnonymizedProxy } from 'proxy-chain';
-import { DEFAULT_USER_AGENT, ENV_VARS } from './constants';
+import { ENV_VARS } from 'apify-shared/consts';
+import { DEFAULT_USER_AGENT } from './constants';
import { newPromise } from './utils';
/* global process, require */
diff --git a/test/_helper.js b/test/_helper.js
index d3b30e19d..89d5cbb76 100644
--- a/test/_helper.js
+++ b/test/_helper.js
@@ -1,7 +1,7 @@
import fs from 'fs-extra';
import path from 'path';
import { expect } from 'chai';
-import { ENV_VARS } from '../build/constants';
+import { ENV_VARS } from 'apify-shared/consts';
export const LOCAL_STORAGE_DIR = path.join(__dirname, '..', 'tmp', 'local-emulation-dir');
diff --git a/test/actor.js b/test/actor.js
index 398506b45..9f61505a6 100644
--- a/test/actor.js
+++ b/test/actor.js
@@ -5,7 +5,7 @@ import 'babel-polyfill';
import sinon from 'sinon';
import Promise from 'bluebird';
import { delayPromise } from 'apify-shared/utilities';
-import { ACT_TASK_STATUSES, ENV_VARS, LOCAL_ENV_VARS } from '../build/constants';
+import { ENV_VARS, ACT_TASK_STATUSES, LOCAL_ENV_VARS } from 'apify-shared/consts';
import { ApifyCallError } from '../build/errors';
chai.use(chaiAsPromised);
diff --git a/test/autoscaled_pool.js b/test/autoscaled_pool.js
index 8f4616937..0f5824427 100644
--- a/test/autoscaled_pool.js
+++ b/test/autoscaled_pool.js
@@ -5,8 +5,8 @@ import _ from 'underscore';
import sinon from 'sinon';
import { delayPromise } from 'apify-shared/utilities';
import log from 'apify-shared/log';
+import { ACTOR_EVENT_NAMES, ENV_VARS } from 'apify-shared/consts';
import * as Apify from '../build/index';
-import { ACTOR_EVENT_NAMES, ENV_VARS } from '../build/constants';
import { SCALE_UP_MAX_STEP, SCALE_UP_INTERVAL, SCALE_DOWN_INTERVAL } from '../build/autoscaled_pool';
import * as utils from '../build/utils';
diff --git a/test/constants.js b/test/constants.js
index 026d2de00..5b1f5196e 100644
--- a/test/constants.js
+++ b/test/constants.js
@@ -1,5 +1,6 @@
import { expect } from 'chai';
-import { ACTOR_BASE_DOCKER_IMAGES, BUILD_TAG_LATEST, ENV_VARS } from '../build/constants';
+import { ACTOR_BASE_DOCKER_IMAGES, BUILD_TAG_LATEST, ENV_VARS } from 'apify-shared/consts';
+import { ACTOR_EVENT_NAMES_EX } from '../build/constants';
describe('consts', () => {
it('should contain constants from apify-shared', () => {
@@ -9,5 +10,7 @@ describe('consts', () => {
it('should contain local constants', () => {
expect(ENV_VARS).to.be.a('object');
+ expect(ACTOR_EVENT_NAMES_EX.CPU_INFO).to.be.eql('cpuInfo');
+ expect(ACTOR_EVENT_NAMES_EX.PERSIST_STATE).to.be.eql('persistState');
});
});
diff --git a/test/dataset.js b/test/dataset.js
index 281af9639..cbdde6293 100644
--- a/test/dataset.js
+++ b/test/dataset.js
@@ -5,7 +5,7 @@ import fs from 'fs-extra';
import path from 'path';
import sinon from 'sinon';
import { leftpad } from 'apify-shared/utilities';
-import { ENV_VARS, MAX_PAYLOAD_SIZE_BYTES } from '../build/constants';
+import { ENV_VARS, MAX_PAYLOAD_SIZE_BYTES } from 'apify-shared/consts';
import { LOCAL_FILENAME_DIGITS, Dataset, DatasetLocal, LOCAL_STORAGE_SUBDIR,
LOCAL_GET_ITEMS_DEFAULT_LIMIT, checkAndSerialize, chunkBySize } from '../build/dataset';
import * as utils from '../build/utils';
diff --git a/test/events.js b/test/events.js
index 6e6f17584..761ec2872 100644
--- a/test/events.js
+++ b/test/events.js
@@ -4,7 +4,9 @@ import sinon from 'sinon';
import Promise from 'bluebird';
import { expect } from 'chai';
import { delayPromise } from 'apify-shared/utilities';
-import { ENV_VARS, ACTOR_EVENT_NAMES } from '../build/constants';
+import { ENV_VARS } from 'apify-shared/consts';
+import { ACTOR_EVENT_NAMES_EX } from '../build/constants';
+
import Apify from '../build';
describe('Apify.events', () => {
@@ -46,6 +48,7 @@ describe('Apify.events', () => {
});
process.env[ENV_VARS.ACTOR_EVENTS_WS_URL] = 'ws://localhost:9099/someRunId';
+ process.env[ENV_VARS.TOKEN] = 'dummy';
// Run main and store received events
expect(isWsConnected).to.be.eql(false);
@@ -67,6 +70,7 @@ describe('Apify.events', () => {
stubbedExit.restore();
wss.close();
delete process.env[ENV_VARS.ACTOR_EVENTS_WS_URL];
+ delete process.env[ENV_VARS.TOKEN];
await delayPromise(10); // Here must be short sleep to get following line to later tick
expect(isWsConnected).to.be.eql(false);
done();
@@ -122,7 +126,7 @@ describe('Apify.events', () => {
process.env.APIFY_TEST_PERSIST_INTERVAL_MILLIS = 20;
const eventsReceived = [];
- Apify.events.on(ACTOR_EVENT_NAMES.PERSIST_STATE, data => eventsReceived.push(data));
+ Apify.events.on(ACTOR_EVENT_NAMES_EX.PERSIST_STATE, data => eventsReceived.push(data));
await Apify.initializeEvents();
await delayPromise(115);
await Apify.stopEvents();
diff --git a/test/key_value_store.js b/test/key_value_store.js
index 1c3b1700e..d05c43e1f 100644
--- a/test/key_value_store.js
+++ b/test/key_value_store.js
@@ -3,7 +3,7 @@ import chaiAsPromised from 'chai-as-promised';
import 'babel-polyfill';
import sinon from 'sinon';
import path from 'path';
-import { ENV_VARS } from '../build/constants';
+import { ENV_VARS } from 'apify-shared/consts';
import { KeyValueStoreLocal, KeyValueStore, maybeStringify, getFileNameRegexp, LOCAL_STORAGE_SUBDIR } from '../build/key_value_store';
import * as utils from '../build/utils';
import * as Apify from '../build/index';
@@ -351,4 +351,3 @@ describe('KeyValueStore', () => {
});
});
});
-
diff --git a/test/puppeteer.js b/test/puppeteer.js
index 24fe4c65f..53003aa66 100644
--- a/test/puppeteer.js
+++ b/test/puppeteer.js
@@ -6,9 +6,9 @@ import basicAuthParser from 'basic-auth-parser';
import Promise from 'bluebird';
import _ from 'underscore';
import sinon from 'sinon';
+import { ENV_VARS } from 'apify-shared/consts';
import Apify from '../build/index';
import * as actor from '../build/actor';
-import { ENV_VARS } from '../build/constants';
import * as utils from '../build/utils';
let prevEnvHeadless;
diff --git a/test/puppeteer_crawler.js b/test/puppeteer_crawler.js
index 1c24da5a9..e979c172f 100644
--- a/test/puppeteer_crawler.js
+++ b/test/puppeteer_crawler.js
@@ -3,7 +3,7 @@ import chaiAsPromised from 'chai-as-promised';
import 'babel-polyfill';
import _ from 'underscore';
import log from 'apify-shared/log';
-import { ENV_VARS } from '../build/constants';
+import { ENV_VARS } from 'apify-shared/consts';
import * as Apify from '../build/index';
chai.use(chaiAsPromised);
diff --git a/test/puppeteer_live_view_server.js b/test/puppeteer_live_view_server.js
index 3059c86d6..0ebc3a2c9 100644
--- a/test/puppeteer_live_view_server.js
+++ b/test/puppeteer_live_view_server.js
@@ -2,9 +2,9 @@ import http from 'http';
import { expect, assert } from 'chai';
import Promise from 'bluebird';
import puppeteer from 'puppeteer';
+import { ENV_VARS } from 'apify-shared/consts';
import Apify from '../build/index';
import PuppeteerLiveViewServer, { PuppeteerLiveViewBrowser } from '../build/puppeteer_live_view_server';
-import { ENV_VARS } from '../build/constants';
const PORT = 0;
const URL = 'thisshouldfailonclientonly';
diff --git a/test/puppeteer_pool.js b/test/puppeteer_pool.js
index e32546c2e..270a9c0a5 100644
--- a/test/puppeteer_pool.js
+++ b/test/puppeteer_pool.js
@@ -4,7 +4,7 @@ import chaiAsPromised from 'chai-as-promised';
import _ from 'underscore';
import log from 'apify-shared/log';
import 'babel-polyfill';
-import { ENV_VARS } from '../build/constants';
+import { ENV_VARS } from 'apify-shared/consts';
import * as Apify from '../build/index';
chai.use(chaiAsPromised);
diff --git a/test/request_list.js b/test/request_list.js
index b6fca79f1..3386a0da9 100644
--- a/test/request_list.js
+++ b/test/request_list.js
@@ -5,9 +5,9 @@ import chaiAsPromised from 'chai-as-promised';
import request from 'request-promise';
import sinon from 'sinon';
import { delayPromise } from 'apify-shared/utilities';
+import { ACTOR_EVENT_NAMES_EX } from '../build/constants';
import Apify from '../build/index';
import * as keyValueStore from '../build/key_value_store';
-import { ACTOR_EVENT_NAMES } from '../build/constants';
import * as utils from '../build/utils';
chai.use(chaiAsPromised);
@@ -420,7 +420,7 @@ describe('Apify.RequestList', () => {
.once()
.withArgs(PERSIST_STATE_KEY, requestList.getState())
.returns(Promise.resolve());
- Apify.events.emit(ACTOR_EVENT_NAMES.PERSIST_STATE);
+ Apify.events.emit(ACTOR_EVENT_NAMES_EX.PERSIST_STATE);
await delayPromise(1);
expect(requestList.isStatePersisted).to.be.eql(true);
@@ -433,7 +433,7 @@ describe('Apify.RequestList', () => {
.once()
.withArgs(PERSIST_STATE_KEY, requestList.getState())
.returns(Promise.resolve());
- Apify.events.emit(ACTOR_EVENT_NAMES.PERSIST_STATE);
+ Apify.events.emit(ACTOR_EVENT_NAMES_EX.PERSIST_STATE);
await delayPromise(1);
expect(requestList.isStatePersisted).to.be.eql(true);
diff --git a/test/request_queue.js b/test/request_queue.js
index 1c96ab509..874ee46f7 100644
--- a/test/request_queue.js
+++ b/test/request_queue.js
@@ -4,8 +4,8 @@ import _ from 'underscore';
import 'babel-polyfill';
import sinon from 'sinon';
import path from 'path';
+import { ENV_VARS } from 'apify-shared/consts';
import * as Apify from '../build/index';
-import { ENV_VARS } from '../build/constants';
import * as utils from '../build/utils';
import { RequestQueueLocal, RequestQueue, LOCAL_STORAGE_SUBDIR, QUERY_HEAD_MIN_LENGTH } from '../build/request_queue';
import { emptyLocalStorageSubdir, LOCAL_STORAGE_DIR, expectNotUsingLocalStorage, expectDirEmpty, expectDirNonEmpty } from './_helper';
diff --git a/test/utils.js b/test/utils.js
index 9805a06df..21534301a 100644
--- a/test/utils.js
+++ b/test/utils.js
@@ -7,9 +7,9 @@ import os from 'os';
import Promise from 'bluebird';
import requestPromise from 'request-promise';
import LruCache from 'apify-shared/lru_cache';
+import { ENV_VARS, LOCAL_ENV_VARS } from 'apify-shared/consts';
import * as utils from '../build/utils';
import Apify from '../build/index';
-import { ENV_VARS, LOCAL_ENV_VARS } from '../build/constants';
chai.use(chaiAsPromised);