Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add debug logs #118

Merged
merged 18 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [unreleased]

## [4.1.0] - 2024-01-03

- Added debug logs to the SDK
- Update contributing Prerequisites
- Remove unused ESLint and Prettier config files from TestingApp

Expand Down
62 changes: 62 additions & 0 deletions TestingApp/test/logger.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved.
*
* This software is licensed under the Apache License, Version 2.0 (the
* "License") as published by the Apache Software Foundation.
*
* You may not use this file except in compliance with the License. You may
* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
const tough = require("tough-cookie");
import SuperTokens from "supertokens-react-native";
import { disableLogging } from "supertokens-react-native/lib/build/logger";
// jest does not call setupFiles properly with the new react-native init, so doing it this way instead
import "./setup";

process.env.TEST_MODE = "testing";

describe("Logger test", () => {
const consoleSpy = jest.spyOn(console, "log");

beforeEach(() => {
disableLogging();
let nodeFetch = require("node-fetch").default;
const fetch = require("fetch-cookie")(nodeFetch, new tough.CookieJar());
global.fetch = fetch;
});

afterEach(() => {
jest.clearAllMocks();
});

it("should log to console when debug logging is enabled", async () => {
SuperTokens.init({
apiDomain: "http://localhost:3000",
enableDebugLogs: true
});

expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining("init: called"));
});

it("should not log to console when debug logging is disabled", async () => {
SuperTokens.init({
apiDomain: "http://localhost:3000",
enableDebugLogs: false
});

expect(consoleSpy).not.toHaveBeenCalledWith(expect.stringContaining("init: called"));
});

it("should not log to console when no argument is passed for enableDebugLogs", async () => {
SuperTokens.init({
apiDomain: "http://localhost:3000"
});

expect(consoleSpy).not.toHaveBeenCalledWith(expect.stringContaining("init: called"));
});
});
14 changes: 14 additions & 0 deletions lib/build/antiCsrf.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading