{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": [],
      "authorship_tag": "ABX9TyMGyK2RVDGVf3zOmV5ZO35X",
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/olafthiele/gtd23/blob/main/Demo_LLM_2_Testing.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "#Ausführen von Tests in Colab"
      ],
      "metadata": {
        "id": "HrF7iKZ38l2d"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Installation des Frameworks nur in Dev\n",
        "!npm install --save-dev jest"
      ],
      "metadata": {
        "id": "Od1hXYFZeaMY"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "9_3CMOh1eIBO"
      },
      "outputs": [],
      "source": [
        "# Code in Datei schreiben\n",
        "# https://jestjs.io/docs/getting-started\n",
        "\n",
        "sum_code = '''\n",
        "function sum(a, b) {\n",
        "  return a + b;\n",
        "}\n",
        "module.exports = sum;\n",
        "'''\n",
        "\n",
        "# Save the person code to person.js file\n",
        "with open('sum.js', 'w') as file:\n",
        "    file.write(sum_code)\n"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "oder so"
      ],
      "metadata": {
        "id": "xR5c5gkr9Cw4"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "%%writefile sum.test.js\n",
        "const sum = require('./sum');\n",
        "\n",
        "test('adds 1 + 2 to equal 3', () => {\n",
        "  expect(sum(1, 2)).toBe(3);\n",
        "});"
      ],
      "metadata": {
        "id": "V1af2mrAfG7D"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "%%writefile package.json\n",
        "{\n",
        "  \"scripts\": {\n",
        "    \"test\": \"jest\"\n",
        "  }\n",
        "}"
      ],
      "metadata": {
        "id": "-3CBSOZ7jeiY"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "Test ausführen"
      ],
      "metadata": {
        "id": "8b6SATFk9F3R"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "!npm test"
      ],
      "metadata": {
        "id": "a41uvgc7i--E"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [],
      "metadata": {
        "id": "19PYFrCAfV3C"
      },
      "execution_count": null,
      "outputs": []
    }
  ]
}