Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
claromes committed May 6, 2024
1 parent 62f1657 commit 4830bbe
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,19 @@ $ `web-ext run -t firefox-android --adb-device <CODE> --firefox-apk org.mozilla.

### Testing wih Puppeteer

Only for Firefox for Desktop and Google Chrome.
To test each group of URLs (Instagram profile, tagged, stories, post and tag, and TikTok profile), it's necessary to pass the group and the browser as options when running the script. This applies only to Firefox for Desktop and Google Chrome.

To test each group of URLs (Instagram profile, tagged, stories, post and tag, and TikTok profile), it's necessary to pass the group as an option when running the script. The groups are: `ig_profile`, `ig_tagged`, `ig_post`, `ig_stories`, `ig_tags`, and `tt_profile`.
The groups are: `ig_profile`, `ig_tagged`, `ig_post`, `ig_stories`, `ig_tags`, and `tt_profile`.

The browsers are: `chrome`, and `firefox`.

Run the test with the desired group:

$ `npm test [group]`
$ `npm test [group] [browser]`

#### Example

To test Instagram profile URLs, run the command `npm test ig_profile`.
To test Instagram profile URLs on Firefox, run the command `npm test ig_profile firefox`.

## Roadmap

Expand Down
34 changes: 31 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
import puppeteer from 'puppeteer';
import path from 'path';
import webExt from 'web-ext';

const option = process.argv[2];
const browserOption = process.argv[3];

if (!option) {
console.error('Please provide a value for the group variable.');
process.exit(1);
}

if (browserOption !== 'chrome' && browserOption !== 'firefox') {
console.error(
'The value for the browser variable must be firefox or chrome.'
);
process.exit(1);
}

const ig_profile = [
'https://instagram.com/instagram',
'https://instagram.com/instagram/',
Expand Down Expand Up @@ -61,8 +70,8 @@ const tt_profile = [

const group = eval(option);

(async () => {
const pathToExtension = path.join(process.cwd(), './src');
async function testChrome(group) {
const pathToExtension = path.join(process.cwd(), './chrome');
const browser = await puppeteer.launch({
headless: false,
args: [
Expand All @@ -77,4 +86,23 @@ const group = eval(option);
const page = await browser.newPage();
await page.goto(url, { waitUntil: 'domcontentloaded' });
}
})();
}

async function testFirefox(group) {
const pathToExtension = path.join(process.cwd(), './firefox');
const options = {
sourceDir: pathToExtension,
firefox: 'C:\\Program Files\\Mozilla Firefox\\firefox.exe',
startUrl: group
};

console.log('The tested URLs are:', group);

await webExt.cmd.run(options);
}

if (browserOption === 'chrome') {
testChrome(group);
} else if (browserOption === 'firefox') {
testFirefox(group);
}

0 comments on commit 4830bbe

Please sign in to comment.