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.
TypeScript apifyautomationcrawlercrawlingheadlessheadless-chromejavascriptnodejsnpmplaywrightpuppeteerscraperscrapingtypescriptweb-crawlerweb-crawlingweb-scraping
Fixing tests
Marek Trunkat884eb42cbe26
diff --git a/package.json b/package.jsonindex 534a43091..0910f2e1f 100644--- a/package.json+++ b/package.json@@ -49,7 +49,7 @@},"dependencies": {"apify-client": "^0.2.9",- "apify-shared": "0.0.50",+ "apify-shared": "0.0.55","bluebird": "^3.5.0","cheerio": "^1.0.0-rc.2","content-type": "^1.0.3",diff --git a/src/actor.js b/src/actor.jsindex da333ec89..2806c77d4 100644--- a/src/actor.js+++ b/src/actor.js@@ -426,7 +426,7 @@ export const getApifyProxyUrl = (opts = {}) => {session,password = process.env[ENV_VARS.PROXY_PASSWORD],hostname = process.env[ENV_VARS.PROXY_HOSTNAME] || LOCAL_ENV_VARS[ENV_VARS.PROXY_HOSTNAME],- port = parseInt(process.env[ENV_VARS.PROXY_PORT], 10) || LOCAL_ENV_VARS[ENV_VARS.PROXY_PORT],+ port = parseInt(process.env[ENV_VARS.PROXY_PORT] || LOCAL_ENV_VARS[ENV_VARS.PROXY_PORT], 10),// This is used only internaly. Some other function calling this function use different naming for groups and session// parameters so we need to override this in error messages.diff --git a/src/dataset.js b/src/dataset.jsindex fd504ea59..b4de4d030 100644--- a/src/dataset.js+++ b/src/dataset.js@@ -7,7 +7,7 @@ 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 { apifyClient, ensureDirExists, openRemoteStorage, openLocalStorage } from './utils';+import { apifyClient, ensureDirExists, openRemoteStorage, openLocalStorage, ensureTokenOrLocalStorageEnvExists } from './utils';export const LOCAL_STORAGE_SUBDIR = LOCAL_STORAGE_SUBDIRS.datasets;export const LOCAL_FILENAME_DIGITS = 9;@@ -109,9 +109,9 @@ export const chunkBySize = (items, limitBytes) => {* such as a list of e-commerce products.* To create an instance of the `Dataset` class, call the [Apify.openDataset()](#module-Apify-openDataset) function.*- * The actual data is either stored in the Apify cloud (see [Dataset storage documentation](https://www.apify.com/docs/storage#dataset)- * when actor is running on Apify platform or `APIFY_PLATFORM_STORAGE=1` environment variable is set- * or on the local disk in the directory `./apify_storage` (overridable by `APIFY_LOCAL_STORAGE_DIR` environment variable).+ * The actual data is either stored on the local disk in the directory defined by `APIFY_LOCAL_STORAGE_DIR` environment variable if provided or+ * in the Apify cloud (see [Dataset storage documentation](https://www.apify.com/docs/storage#dataset) when actor is running on Apify+ * platform if `APIFY_TOKEN` environment variable is set.** Example usage:*@@ -611,10 +611,11 @@ const getOrCreateDataset = (datasetIdOrName) => {*/export const openDataset = (datasetIdOrName) => {checkParamOrThrow(datasetIdOrName, 'datasetIdOrName', 'Maybe String');+ ensureTokenOrLocalStorageEnvExists('dataset');- return process.env[ENV_VARS.PLATFORM_STORAGE]- ? openRemoteStorage(datasetIdOrName, ENV_VARS.DEFAULT_DATASET_ID, Dataset, datasetsCache, getOrCreateDataset)- : openLocalStorage(datasetIdOrName, ENV_VARS.DEFAULT_DATASET_ID, DatasetLocal, datasetsCache);+ return process.env[ENV_VARS.LOCAL_STORAGE_DIR]+ ? openLocalStorage(datasetIdOrName, ENV_VARS.DEFAULT_DATASET_ID, DatasetLocal, datasetsCache)+ : openRemoteStorage(datasetIdOrName, ENV_VARS.DEFAULT_DATASET_ID, Dataset, datasetsCache, getOrCreateDataset);};/**@@ -633,9 +634,9 @@ export const openDataset = (datasetIdOrName) => {* await dataset.pushData({ myValue: 123 });* ```*- * The actual data is either stored in the Apify cloud (see [Dataset storage documentation](https://www.apify.com/docs/storage#dataset)- * when actor is running on Apify platform or `APIFY_PLATFORM_STORAGE=1` environment variable is set- * or on the local disk in the directory `./apify_storage` (overridable by `APIFY_LOCAL_STORAGE_DIR` environment variable) otherwise.+ * The actual data is either stored on the local disk in the directory defined by `APIFY_LOCAL_STORAGE_DIR` environment variable if provided or+ * in the Apify cloud (see [Dataset storage documentation](https://www.apify.com/docs/storage#dataset) when actor is running on Apify+ * platform if `APIFY_TOKEN` environment variable is set.** For more information, see* [Apify.openDataset()](#module-Apify-openDataset) and [Dataset.pushData()](#Dataset-pushData).diff --git a/src/index.js b/src/index.jsindex 9420f0607..a8d71d9e2 100644--- a/src/index.js+++ b/src/index.js@@ -27,11 +27,6 @@ if (!isProduction() || process.env[ENV_VARS.LOG_LEVEL] === 'DEBUG') log.isDebugM// Log as plain text not JSONlog.logJson = false;-// Just warn user that local storage will be used.-if (process.env[ENV_VARS.PLATFORM_STORAGE]) {- log.info(`Using local directory for storage as environment variable ${ENV_VARS.PLATFORM_STORAGE}=1 is not set.`);-}-/***{include-readme-1}*{include-readme-2}diff --git a/src/key_value_store.js b/src/key_value_store.jsindex d04ef7d9e..1cabaefcd 100644--- a/src/key_value_store.js+++ b/src/key_value_store.js@@ -9,7 +9,7 @@ import { KEY_VALUE_STORE_KEY_REGEX } from 'apify-shared/regexs';import { checkParamOrThrow, parseBody } from 'apify-client/build/utils';import { ENV_VARS, LOCAL_STORAGE_SUBDIRS } from './constants';import {- addCharsetToContentType, apifyClient, ensureDirExists, openRemoteStorage, openLocalStorage,+ addCharsetToContentType, apifyClient, ensureDirExists, openRemoteStorage, openLocalStorage, ensureTokenOrLocalStorageEnvExists,} from './utils';export const LOCAL_STORAGE_SUBDIR = LOCAL_STORAGE_SUBDIRS.keyValueStores;@@ -98,9 +98,9 @@ export const maybeStringify = (value, options) => {* You should not instantiate this class directly, use the* [Apify.openKeyValueStore()](#module-Apify-openKeyValueStore) function.*- * The actual data is either stored in the Apify cloud (see [Key-value stores documentation](https://www.apify.com/docs/storage#key-value-store)- * when actor is running on Apify platform or `APIFY_PLATFORM_STORAGE=1` environment variable is set- * or on the local disk in the directory `./apify_storage` (overridable by `APIFY_LOCAL_STORAGE_DIR` environment variable).+ * The actual data is either stored on the local disk in the directory defined by `APIFY_LOCAL_STORAGE_DIR` environment variable if provided or+ * in the Apify cloud (see [Key-value stores documentation](https://www.apify.com/docs/storage#key-value-store) when actor is running on Apify+ * platform if `APIFY_TOKEN` environment variable is set.** Example usage:*@@ -352,9 +352,9 @@ const getOrCreateKeyValueStore = (storeIdOrName) => {* Key-value store is a simple storage for records, where each record has a unique key.* For more information, see [Key-value store documentation](https://www.apify.com/docs/storage#dataset).*- * The actual data is either stored in the Apify cloud (see [Key-value stores documentation](https://www.apify.com/docs/storage#key-value-store)- * when actor is running on Apify platform or `APIFY_PLATFORM_STORAGE=1` environment variable is set- * or on the local disk in the directory `./apify_storage` (overridable by `APIFY_LOCAL_STORAGE_DIR` environment variable).+ * The actual data is either stored on the local disk in the directory defined by `APIFY_LOCAL_STORAGE_DIR` environment variable if provided or+ * in the Apify cloud (see [Key-value stores documentation](https://www.apify.com/docs/storage#key-value-store) when actor is running on Apify+ * platform if `APIFY_TOKEN` environment variable is set.** Example usage:*@@ -374,10 +374,11 @@ const getOrCreateKeyValueStore = (storeIdOrName) => {*/export const openKeyValueStore = (storeIdOrName) => {checkParamOrThrow(storeIdOrName, 'storeIdOrName', 'Maybe String');+ ensureTokenOrLocalStorageEnvExists('key value store');- return process.env[ENV_VARS.PLATFORM_STORAGE]- ? openRemoteStorage(storeIdOrName, ENV_VARS.DEFAULT_KEY_VALUE_STORE_ID, KeyValueStore, storesCache, getOrCreateKeyValueStore)- : openLocalStorage(storeIdOrName, ENV_VARS.DEFAULT_KEY_VALUE_STORE_ID, KeyValueStoreLocal, storesCache);+ return process.env[ENV_VARS.LOCAL_STORAGE_DIR]+ ? openLocalStorage(storeIdOrName, ENV_VARS.DEFAULT_KEY_VALUE_STORE_ID, KeyValueStoreLocal, storesCache)+ : openRemoteStorage(storeIdOrName, ENV_VARS.DEFAULT_KEY_VALUE_STORE_ID, KeyValueStore, storesCache, getOrCreateKeyValueStore);};/**@@ -402,11 +403,11 @@ export const openKeyValueStore = (storeIdOrName) => {* For all other content types, the body is a raw `Buffer`.* If the record cannot be found, the result is null.*- * If the actor is not running on Apify platform and `APIFY_PLATFORM_STORAGE=1` environment variable is not set- * the value is read from a local directory `./apify_storage` (overridable by `APIFY_LOCAL_STORAGE_DIR` environment variable)- * rather than the Apify key-value store cloud storage, specifically from a file that has the key as a name.- * If file does not exists, the returned value is `null`. The file will get extension based on it's content type.- * This feature is useful for local development and debugging of your actors.+ * If the actor is not running on Apify platform and `APIFY_LOCAL_STORAGE_DIR` environment variable is set+ * the value is read from a local directory rather than the Apify key-value store cloud storage, specifically+ * from a file that has the key as a name. If file does not exists, the returned value is `null`. The file+ * will get extension based on it's content type. This feature is useful for local development and debugging+ * of your actors.** @param {String} key Key of the record.* @returns {Promise} Returns a promise.@@ -435,11 +436,11 @@ export const getValue = key => openKeyValueStore().then(store => store.getValue(* ```* In this case, the value must be a string or Buffer.*- * If the actor is not running on Apify platform and `APIFY_PLATFORM_STORAGE=1` environment variable is not set- * the value is written to a local directory `./apify_storage` (overridable by `APIFY_LOCAL_STORAGE_DIR` environment variable)- * rather than the Apify key-value store cloud storage, specifically to a file that has the key as a name.- * The file will get extension based on it's content type.- * This feature is useful for local development and debugging of your actors.+ * If the actor is not running on Apify platform and `APIFY_LOCAL_STORAGE_DIR` environment variable is set+ * the value is written a local directory rather than the Apify key-value store cloud storage, specifically+ * from a file that has the key as a name. If file does not exists, the returned value is `null`. The file+ * will get extension based on it's content type. This feature is useful for local development and debugging+ * of your actors.** **IMPORTANT:** Do not forget to use the `await` keyword when calling `Apify.setValue()`,* otherwise the actor process might finish before the value is stored!diff --git a/src/request_queue.js b/src/request_queue.jsindex 9fa8ae884..4f6017e13 100644--- a/src/request_queue.js+++ b/src/request_queue.js@@ -10,7 +10,7 @@ import crypto from 'crypto';import _ from 'underscore';import Request from './request';import { ENV_VARS, LOCAL_STORAGE_SUBDIRS } from './constants';-import { ensureDirExists, apifyClient, openRemoteStorage, openLocalStorage } from './utils';+import { ensureDirExists, apifyClient, openRemoteStorage, openLocalStorage, ensureTokenOrLocalStorageEnvExists } from './utils';export const LOCAL_STORAGE_SUBDIR = LOCAL_STORAGE_SUBDIRS.requestQueues;const MAX_OPENED_QUEUES = 1000;@@ -766,9 +766,9 @@ const getOrCreateQueue = (queueIdOrName) => {* queue.reclaimRequest(request2);* ```*- * The actual data is either stored in the Apify cloud (see [Request queue documentation](https://www.apify.com/docs/storage#queue)- * when actor is running on Apify platform or `APIFY_PLATFORM_STORAGE=1` environment variable is set- * or on the local disk in the directory `./apify_storage` (overridable by `APIFY_LOCAL_STORAGE_DIR` environment variable).+ * The actual data is either stored on the local disk in the directory defined by `APIFY_LOCAL_STORAGE_DIR` environment variable if provided or+ * in the Apify cloud (see [Request queue documentation](https://www.apify.com/docs/storage#queue) when actor is running on Apify+ * platform if `APIFY_TOKEN` environment variable is set.** @param {string} queueIdOrName ID or name of the request queue to be opened.* @returns {Promise<RequestQueue>} Returns a promise that resolves to a `RequestQueue` object. If no value is provided@@ -782,8 +782,9 @@ const getOrCreateQueue = (queueIdOrName) => {*/export const openRequestQueue = (queueIdOrName) => {checkParamOrThrow(queueIdOrName, 'queueIdOrName', 'Maybe String');+ ensureTokenOrLocalStorageEnvExists('request queue');- return process.env[ENV_VARS.PLATFORM_STORAGE]- ? openRemoteStorage(queueIdOrName, ENV_VARS.DEFAULT_REQUEST_QUEUE_ID, RequestQueue, queuesCache, getOrCreateQueue)- : openLocalStorage(queueIdOrName, ENV_VARS.DEFAULT_REQUEST_QUEUE_ID, RequestQueueLocal, queuesCache);+ return process.env[ENV_VARS.LOCAL_STORAGE_DIR]+ ? openLocalStorage(queueIdOrName, ENV_VARS.DEFAULT_REQUEST_QUEUE_ID, RequestQueueLocal, queuesCache)+ : openRemoteStorage(queueIdOrName, ENV_VARS.DEFAULT_REQUEST_QUEUE_ID, RequestQueue, queuesCache, getOrCreateQueue);};diff --git a/src/utils.js b/src/utils.jsindex 5f1a3c15f..4551ac505 100644--- a/src/utils.js+++ b/src/utils.js@@ -429,6 +429,16 @@ export const openRemoteStorage = async (idOrName, defaultIdEnvVar, RemoteClass,return storagePromise;};+/**+ * Checks if at least one of APIFY_LOCAL_STORAGE_DIR and APIFY_TOKEN environment variables is set.+ */+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 APIFY_LOCAL_STORAGE_DIR nor APIFY_TOKEN environment variable is not set.`+ + 'Configure APIFY_LOCAL_STORAGE_DIR to enable storage in local directory or APIFY_TOKEN to use Apify cloud for storages.');+ }+};+/*** A namespace that contains various utilities.*diff --git a/test/_helper.js b/test/_helper.jsindex c56a813df..d3b30e19d 100644--- a/test/_helper.js+++ b/test/_helper.js@@ -5,8 +5,6 @@ import { ENV_VARS } from '../build/constants';export const LOCAL_STORAGE_DIR = path.join(__dirname, '..', 'tmp', 'local-emulation-dir');-process.env[ENV_VARS.LOCAL_STORAGE_DIR] = LOCAL_STORAGE_DIR;-// Log unhandled rejections.process.on('unhandledRejection', (err) => {console.log('---------------------------------------------------------------------');@@ -24,7 +22,7 @@ export const emptyLocalStorageSubdir = (subdir) => {fs.emptyDirSync(fullPath);};-export const expectNotUsingLocalStorage = () => expect(process.env[ENV_VARS.PLATFORM_STORAGE]).to.be.a('undefined');+export const expectNotUsingLocalStorage = () => expect(process.env[ENV_VARS.LOCAL_STORAGE_DIR]).to.be.a('undefined');export const expectDirEmpty = (dirPath) => {const content = fs.readdirSync(dirPath);diff --git a/test/dataset.js b/test/dataset.jsindex c11629a06..281af9639 100644--- a/test/dataset.js+++ b/test/dataset.js@@ -725,17 +725,18 @@ describe('dataset', () => {it('should work', () => {const mock = sinon.mock(utils);- delete process.env[ENV_VARS.PLATFORM_STORAGE];+ process.env[ENV_VARS.LOCAL_STORAGE_DIR] = LOCAL_STORAGE_DIR;mock.expects('openLocalStorage').once();Apify.openDataset();- process.env[ENV_VARS.PLATFORM_STORAGE] = '1';+ delete process.env[ENV_VARS.LOCAL_STORAGE_DIR];+ process.env[ENV_VARS.TOKEN] = 'xxx';mock.expects('openRemoteStorage').once();Apify.openDataset();- delete process.env[ENV_VARS.PLATFORM_STORAGE];+ delete process.env[ENV_VARS.TOKEN];mock.verify();mock.restore();@@ -745,6 +746,7 @@ describe('dataset', () => {describe('pushData', async () => {it('throws on invalid args', async () => {process.env[ENV_VARS.DEFAULT_DATASET_ID] = 'some-id-8';+ process.env[ENV_VARS.LOCAL_STORAGE_DIR] = LOCAL_STORAGE_DIR;const dataErrMsg = 'Parameter "data" of type Array | Object must be provided';await expect(Apify.pushData()).to.be.rejectedWith(dataErrMsg);@@ -760,10 +762,12 @@ describe('dataset', () => {await expect(Apify.pushData(circularObj)).to.be.rejectedWith(jsonErrMsg);delete process.env[ENV_VARS.DEFAULT_DATASET_ID];+ delete process.env[ENV_VARS.LOCAL_STORAGE_DIR];});it('throws if DEFAULT_DATASET_ID env var is not defined and we use cloud storage', async () => {- process.env[ENV_VARS.PLATFORM_STORAGE] = '1';+ delete process.env[ENV_VARS.LOCAL_STORAGE_DIR];+ process.env[ENV_VARS.TOKEN] = 'xxx';process.env[ENV_VARS.DEFAULT_DATASET_ID] = '';await expect(Apify.pushData({ something: 123 })).to.be.rejectedWith(Error);@@ -771,10 +775,11 @@ describe('dataset', () => {delete process.env[ENV_VARS.DEFAULT_DATASET_ID];await expect(Apify.pushData({ something: 123 })).to.be.rejectedWith(Error);- delete process.env[ENV_VARS.PLATFORM_STORAGE];+ delete process.env[ENV_VARS.TOKEN];});it('correctly stores records', async () => {+ process.env[ENV_VARS.LOCAL_STORAGE_DIR] = LOCAL_STORAGE_DIR;process.env[ENV_VARS.DEFAULT_DATASET_ID] = 'some-id-9';await Apify.pushData({ foo: 'bar' });@@ -784,6 +789,7 @@ describe('dataset', () => {expect(read('some-id-9', 2)).to.be.eql({ foo: 'hotel' });delete process.env[ENV_VARS.DEFAULT_DATASET_ID];+ delete process.env[ENV_VARS.LOCAL_STORAGE_DIR];});});diff --git a/test/key_value_store.js b/test/key_value_store.jsindex 4678b3c65..1c3b1700e 100644--- a/test/key_value_store.js+++ b/test/key_value_store.js@@ -160,20 +160,21 @@ describe('KeyValueStore', () => {});describe('Apify.openKeyValueStore', async () => {- it('should work', () => {+ it('should work', async () => {const mock = sinon.mock(utils);- delete process.env[ENV_VARS.PLATFORM_STORAGE];+ process.env[ENV_VARS.LOCAL_STORAGE_DIR] = LOCAL_STORAGE_DIR;mock.expects('openLocalStorage').once();- Apify.openKeyValueStore();+ await Apify.openKeyValueStore();- process.env[ENV_VARS.PLATFORM_STORAGE] = '1';+ delete process.env[ENV_VARS.LOCAL_STORAGE_DIR];+ process.env[ENV_VARS.TOKEN] = 'xxx';mock.expects('openRemoteStorage').once();- Apify.openKeyValueStore();+ await Apify.openKeyValueStore();- delete process.env[ENV_VARS.PLATFORM_STORAGE];+ delete process.env[ENV_VARS.TOKEN];mock.verify();mock.restore();@@ -183,30 +184,30 @@ describe('KeyValueStore', () => {describe('getValue', async () => {it('throws on invalid args', async () => {process.env[ENV_VARS.DEFAULT_KEY_VALUE_STORE_ID] = '1234';+ process.env[ENV_VARS.LOCAL_STORAGE_DIR] = LOCAL_STORAGE_DIR;await expect(Apify.getValue()).to.be.rejectedWith('Parameter "key" of type String must be provided');await expect(Apify.getValue({})).to.be.rejectedWith('Parameter "key" of type String must be provided');await expect(Apify.getValue('')).to.be.rejectedWith('The "key" parameter cannot be empty');await expect(Apify.getValue(null)).to.be.rejectedWith('Parameter "key" of type String must be provided');+ delete process.env[ENV_VARS.LOCAL_STORAGE_DIR];});it('throws if APIFY_DEFAULT_KEY_VALUE_STORE_ID env var is not defined and we use cloud storage', async () => {- process.env[ENV_VARS.PLATFORM_STORAGE] = '1';+ delete process.env[ENV_VARS.LOCAL_STORAGE_DIR];+ delete process.env[ENV_VARS.DEFAULT_KEY_VALUE_STORE_ID];+ process.env[ENV_VARS.TOKEN] = 'xxx';const errMsg = 'The \'APIFY_DEFAULT_KEY_VALUE_STORE_ID\' environment variable is not defined';-- process.env[ENV_VARS.DEFAULT_KEY_VALUE_STORE_ID] = '';await expect(Apify.getValue('KEY')).to.be.rejectedWith(errMsg);- delete process.env[ENV_VARS.DEFAULT_KEY_VALUE_STORE_ID];- await expect(Apify.getValue('some other key')).to.be.rejectedWith(errMsg);-- delete process.env[ENV_VARS.PLATFORM_STORAGE];+ delete process.env[ENV_VARS.TOKEN];});});describe('setValue', async () => {it('throws on invalid args', async () => {process.env[ENV_VARS.DEFAULT_KEY_VALUE_STORE_ID] = '12345';+ process.env[ENV_VARS.LOCAL_STORAGE_DIR] = LOCAL_STORAGE_DIR;await expect(Apify.setValue()).to.be.rejectedWith('Parameter "key" of type String must be provided');await expect(Apify.setValue('', null)).to.be.rejectedWith('The "key" parameter cannot be empty');await expect(Apify.setValue('', 'some value')).to.be.rejectedWith('The "key" parameter cannot be empty');@@ -243,6 +244,8 @@ describe('KeyValueStore', () => {await expect(Apify.setValue('key', 'value', { contentType: new Date() })).to.be.rejectedWith(contTypeStringErrMsg);await expect(Apify.setValue('key', 'value', { contentType: '' })).to.be.rejectedWith('Parameter options.contentType cannot be empty string.');++ delete process.env[ENV_VARS.LOCAL_STORAGE_DIR];});it('throws on invalid characters in key', async () => {@@ -262,17 +265,14 @@ describe('KeyValueStore', () => {});it('throws if APIFY_DEFAULT_KEY_VALUE_STORE_ID env var is not defined and we use cloud storage', async () => {- process.env[ENV_VARS.PLATFORM_STORAGE] = 1;+ delete process.env[ENV_VARS.DEFAULT_KEY_VALUE_STORE_ID];+ delete process.env[ENV_VARS.LOCAL_STORAGE_DIR];+ process.env[ENV_VARS.TOKEN] = 'xxx';const errMsg = 'The \'APIFY_DEFAULT_KEY_VALUE_STORE_ID\' environment variable is not defined';-- process.env[ENV_VARS.DEFAULT_KEY_VALUE_STORE_ID] = '';await expect(Apify.setValue('KEY', {})).to.be.rejectedWith(errMsg);- delete process.env[ENV_VARS.DEFAULT_KEY_VALUE_STORE_ID];- await expect(Apify.setValue('some other key', {})).to.be.rejectedWith(errMsg);-- delete process.env[ENV_VARS.PLATFORM_STORAGE];+ delete process.env[ENV_VARS.TOKEN];});it('correctly adds charset to content type', async () => {diff --git a/test/request_queue.js b/test/request_queue.jsindex 4a2c72b8c..1c96ab509 100644--- a/test/request_queue.js+++ b/test/request_queue.js@@ -374,17 +374,18 @@ describe('RequestQueue', () => {it('should work', () => {const mock = sinon.mock(utils);- delete process.env[ENV_VARS.PLATFORM_STORAGE];+ process.env[ENV_VARS.LOCAL_STORAGE_DIR] = LOCAL_STORAGE_DIR;mock.expects('openLocalStorage').once();Apify.openRequestQueue();- process.env[ENV_VARS.PLATFORM_STORAGE] = '1';+ delete process.env[ENV_VARS.LOCAL_STORAGE_DIR];+ process.env[ENV_VARS.TOKEN] = 'xxx';mock.expects('openRemoteStorage').once();Apify.openRequestQueue();- delete process.env[ENV_VARS.PLATFORM_STORAGE];+ delete process.env[ENV_VARS.TOKEN];mock.verify();mock.restore();