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.

Fixed a bug - old reference to Actor.heyIAmReady(), added a test case for that to unit tests, bumped package.json version

Jan Curn983d1275e72f
diff --git a/build/actor.js b/build/actor.js
index 0dfe3c5a3..cfb2c3286 100644
--- a/build/actor.js
+++ b/build/actor.js
@@ -68,7 +68,7 @@ var main = exports.main = function main(userFunc) {
// TODO: handle errors!
app.listen(serverPort, function () {
// console.log(`Listening on port ${serverPort}`);
- Actor.heyIAmReady();
+ heyIAmReady();
});
};
diff --git a/build/index.js b/build/index.js
index cd694ac88..ff3b6f1a1 100644
--- a/build/index.js
+++ b/build/index.js
@@ -11,6 +11,6 @@ var Apifier = {
getPromisesDependency: _utils.getPromisesDependency
};
-// export this way so the we can import using:
+// export this way so that we can import using:
// const Apifier = require('apifier');
module.exports = Apifier;
\ No newline at end of file
diff --git a/package.json b/package.json
index fb38fdacc..346f31e40 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "apifier",
- "version": "0.0.14",
+ "version": "0.0.15",
"description": "Apifier SDK for JavaScript",
"main": "build/index.js",
"keywords": [
diff --git a/src/actor.js b/src/actor.js
index 4b900c826..58f480d1c 100644
--- a/src/actor.js
+++ b/src/actor.js
@@ -56,7 +56,7 @@ export const main = (userFunc) => {
// TODO: handle errors!
app.listen(serverPort, () => {
// console.log(`Listening on port ${serverPort}`);
- Actor.heyIAmReady();
+ heyIAmReady();
});
};
diff --git a/test/actor.js b/test/actor.js
index fe2a7bba3..918a2df54 100644
--- a/test/actor.js
+++ b/test/actor.js
@@ -9,6 +9,30 @@ if (process.env.TEST_BABEL_BUILD) console.log('Running with TEST_BABEL_BUILD opt
/* global process */
+
+const createWatchFile = () => {
+ const tmpobj = tmp.fileSync();
+ const path = tmpobj.name;
+ fs.writeSync(tmpobj.fd, 'bla bla bla bla');
+
+ const stat = fs.statSync(path);
+ expect(stat.size).to.be.greaterThan(0);
+ return path;
+};
+
+const testWatchFileEmpty = (path) => {
+ return new Promise((resolve, reject) => {
+ setTimeout(() => {
+ const stat = fs.statSync(path);
+ if (stat.size !== 0) {
+ reject('Watch file not written');
+ } else {
+ resolve();
+ }
+ }, 100);
+ });
+};
+
// TODO: run tests against build scripts too!
describe('Apifier.main()', () => {
@@ -39,34 +63,19 @@ describe('Apifier.main()', () => {
it('should work well', () => {
// TODO: pick non-used port number
+ process.env.APIFIER_WATCH_FILE = createWatchFile();
process.env.APIFIER_INTERNAL_PORT = 12345;
// TODO: use watch file
Apifier.main(() => {});
+ return testWatchFileEmpty(process.env.APIFIER_WATCH_FILE);
});
});
describe('Apifier.heyIAmReady()', () => {
it('it works as expected', () => {
- const tmpobj = tmp.fileSync();
- const path = tmpobj.name;
- fs.writeSync(tmpobj.fd, 'bla bla bla bla');
-
- let stat = fs.statSync(path);
- expect(stat.size).to.be.greaterThan(0);
-
- process.env.APIFIER_WATCH_FILE = path;
+ process.env.APIFIER_WATCH_FILE = createWatchFile();
Apifier.heyIAmReady();
-
- return new Promise((resolve, reject) => {
- setTimeout(() => {
- stat = fs.statSync(path);
- if (stat.size !== 0) {
- reject('Watch file not written');
- } else {
- resolve();
- }
- }, 100);
- });
+ return testWatchFileEmpty(process.env.APIFIER_WATCH_FILE);
});
});