Skip to content

Commit

Permalink
chore: only run login tests if credentials are provided
Browse files Browse the repository at this point in the history
  • Loading branch information
catdevnull authored and karashiiro committed Apr 7, 2024
1 parent 4ab9e49 commit 6ec2c93
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/auth.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { getScraper } from './test-utils';

test('scraper can log in', async () => {
const scraper = await getScraper({ authMethod: 'password' });
await expect(scraper.isLoggedIn()).resolves.toBeTruthy();
}, 15000);
const testLogin = process.env['TWITTER_PASSWORD'] ? test : test.skip;

testLogin(
'scraper can log in',
async () => {
const scraper = await getScraper({ authMethod: 'password' });
await expect(scraper.isLoggedIn()).resolves.toBeTruthy();
},
15000,
);

test('scraper can log in with cookies', async () => {
const scraper = await getScraper();
Expand All @@ -22,11 +28,15 @@ test('scraper can restore its login state from cookies', async () => {
await expect(scraper2.isLoggedIn()).resolves.toBeTruthy();
});

test('scraper can log out', async () => {
const scraper = await getScraper({ authMethod: 'password' });
await expect(scraper.isLoggedIn()).resolves.toBeTruthy();
testLogin(
'scraper can log out',
async () => {
const scraper = await getScraper({ authMethod: 'password' });
await expect(scraper.isLoggedIn()).resolves.toBeTruthy();

await scraper.logout();
await scraper.logout();

await expect(scraper.isLoggedIn()).resolves.toBeFalsy();
}, 15000);
await expect(scraper.isLoggedIn()).resolves.toBeFalsy();
},
15000,
);

0 comments on commit 6ec2c93

Please sign in to comment.