How to use clearSessions method in Cypress

Best JavaScript code snippet using cypress

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

sessions.js

Source: sessions.js Github

copy
1const { ipcRenderer } = require('electron');
2
3export function removeSession(session) {
4  return async (dispatch: () => void) => {
5    ipcRenderer.send('removeSession', session);
6  };
7}
8
9export function clearSessions() {
10  return async (dispatch: () => void) => {
11    ipcRenderer.send('clearSessions');
12  };
13}
14
15export default {
16  clearSessions,
17  removeSession,
18};
19
Full Screen

index.jsx

Source: index.jsx Github

copy
1import React, { Component } from 'react';
2import AppBar from 'material-ui/AppBar';
3import { Link } from 'react-router';
4import NavMenuIcon from './NavMenuIcon';
5
6class AppNavBar extends Component {
7  constructor(props, context) {
8    super(props);
9    this.logIn = this.props.logIn.bind(this);
10    this.logOut = this.props.logOut.bind(this);
11    this.clearSessions = this.clearSessions.bind(this);
12    this.FBAuth = this.FBAuth.bind(this);
13    console.log("this.props.user", this.props.user);
14  }
15
16  clearSessions() {
17    $.get("/logout", (resp, err) => {
18      this.logOut();
19    });
20  }
21
22  // this is written so that passport can do auth and not throw a react warning
23  FBAuth(e) {
24    e.preventDefault();
25    const linkTag = $('<a href="/auth/facebook"></a>');
26    linkTag[0].click();
27  }
28
29  render() {
30    // console.log('tpu', this.props.userInstruments);
31    return (
32      <div className="nav">
33        <AppBar
34          showMenuIconButton={false}
35          title="Jam with Friends"
36          titleStyle={{ color: '#E8AEB7', cursor: 'pointer', flex: '' }}
37          onTitleTouchTap={() => { this.context.router.push('/'); }}
38          style={{ backgroundColor: 'rgba(255, 255, 255, 0.8)', height: '100%' }}
39          iconElementRight={
40            <NavMenuIcon
41              id="menuicon"
42              loggedIn={this.props.loggedIn}
43              clearSessions={this.clearSessions}
44              FBAuth={this.FBAuth}
45            />
46          }
47        />
48      </div>
49    ); }
50  }
51
52AppNavBar.contextTypes = {
53  router: React.PropTypes.object
54};
55
56AppNavBar.propTypes = {
57  title: React.PropTypes.string,
58  loggedIn: React.PropTypes.bool,
59  user: React.PropTypes.string,
60  logOut: React.PropTypes.func,
61  logIn: React.PropTypes.func,
62};
63
64export default AppNavBar;
65
Full Screen

session.js

Source: session.js Github

copy
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.clearSessions = exports.getState = exports.getSession = exports.saveSession = void 0;
4const state = {
5    sessions: {},
6};
7function saveSession(data) {
8    if (!data.id)
9        throw new Error('session data had no id');
10    state.sessions[data.id] = data;
11}
12exports.saveSession = saveSession;
13function getSession(id) {
14    const session = state.sessions[id];
15    if (!session)
16        throw new Error(`session with id "${id}" not found`);
17    return session;
18}
19exports.getSession = getSession;
20function getState() {
21    return state;
22}
23exports.getState = getState;
24function clearSessions() {
25    state.sessions = {};
26}
27exports.clearSessions = clearSessions;
28
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run JavaScript Tests on LambdaTest Cloud Grid

Execute automation tests with Cypress on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)