sitemapper
Version:
Parser for XML Sitemaps to be used with Robots.txt and web crawlers
27 lines (26 loc) • 1.1 kB
JavaScript
import { execFile } from 'child_process';
import * as path from 'path';
import { describe, it } from 'mocha';
describe('CLI: sitemapper', function () {
this.timeout(10000); // Allow up to 10 seconds for network
it('should print URLs from the sitemap', function (done) {
// Use a relative path from current working directory instead of __dirname
const cliPath = path.resolve(process.cwd(), 'bin/sitemapper.js');
const sitemapUrl = 'https://wp.seantburke.com/sitemap.xml';
// @ts-ignore - TypeScript has trouble with Node.js execFile overloads
execFile('node', [cliPath, sitemapUrl], (error, stdout, stderr) => {
if (error) {
done(error);
return;
}
// Just check that we have some output and the expected header
const output = stdout.toString();
if (output.includes('Found URLs:')) {
done();
}
else {
done(new Error('Expected CLI output to contain "Found URLs:" header'));
}
});
});
});