Difficulties encountered while executing jest alongside bootstrap-vue

I've been encountering errors while trying to set up unit tests with jest and bootstrap-vue. The errors specifically mention unknown custom elements like:

  • [Vue warn]: Unknown custom element: b-navbar - did you register the component correctly?...
  • [Vue warn]: Unknown custom element: b-navbar-nav - did you register the component correctly? …
  • [Vue warn]: Unknown custom element: b-button - did you register the component correctly? …

Below is the source code that may provide some insight into resolving this issue. Your help would be greatly appreciated! ;-)


//Package.json

{
  "name": "theappname",
  "version": "1.0.0",
  "repository": {
    "type": "git",
    "url": ""
  },
  // Other package.json content...
}

`//Webpack.config.js

var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    mode: 'development',
    resolve: {
        extensions: ['.js', '.vue']
    },
    module: {
        rules: [
            // Webpack configuration rules...
        ]
    },
    entry: {
      index: './src/index.js'
    },
    // Output configuration...
    plugins: [new HtmlWebpackPlugin({
        favicon: './src/public/favicon.png',
        template: './src/index.html',
        filename: "./index.html"
    })],
    devServer: {
        // Dev server configurations...
    },
    externals: {
        // External config object settings...
    }
}

//components.Navbar.spec.js
import BootstrapVue, { BNavbar, BNavbarBrand } from 'bootstrap-vue';
import Vuex from 'vuex'
import Router from 'vue-router';
import { createLocalVue, mount, shallowMount } from '@vue/test-utils';
import Navbar from '@/components/Navbar';

// Test file for Navbar component...

//Navbar.vue
<template>
  <div>
    <b-navbar toggleable="lg">
      <b-navbar-brand href="/"><img src="../assets/logo_250.png">theappname</b-navbar-brand>
      <b-navbar-toggle target="nav-collapse"></b-navbar-toggle>

      // Navbar component HTML structure...
    </b-navbar>
  </div>
</template>

<script>
import { mapState, mapActions } from 'vuex'

export default {
    // Vue component logic...
}

Answer №1

After some investigation, I discovered the answer was not located in the indicated files but rather in the .babelrc file

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Validation of default values in contact forms

Obtained a free contact form online and hoping it works flawlessly, but struggling with validation for fields like "Full Name" in JS and PHP. Here is the HTML code: <input type="text" name="contactname" id="contactname" class="required" role="inpu ...

Limiting the display of JSON data on a webpage using jQuery

I have a code snippet on my website that displays JSON data on an HTML page. The issue is that there is a large amount of data in the JSON file. How can I limit the number of movies (data) being displayed to just 5? function actors(actors) { return ` ...

The new experimental appDir feature in Next.js 13 is failing to display <meta> or <title> tags in the <head> section when rendering on the server

I'm currently experimenting with the new experimental appDir feature in Next.js 13, and I've encountered a small issue. This project is utilizing: Next.js 13 React 18 MUI 5 (styled components using @mui/system @emotion/react @emotion/styled) T ...

Fill a grid child with an excessive amount of content without specifying a fixed height

Check out this JS Fiddle example .grid { height:100%; display:grid; grid-template-rows:auto 1fr; background-color:yellow; } .lots-of-content-div { height:100%; background-color:orange; overflow-y:auto; } <div class="grid"> <p&g ...

There seems to be an issue with Node.js/Express: the page at /

Recently, I've been working on some code (specifically in app.js on the server). console.log("Server started. If you're reading this then your computer is still alive."); //Just a test command to ensure everything is functioning correctly. var ...

JQuery draggable and JavaScript functionality become disabled following an AJAX request

I have a click event declared as follows: $('body').on('click', 'input#searchVariables', function () { var datasetId = $('.TSDatasetID').val(); var term = $('#searchTextbox').val(); ...

Vue alert: Issue encountered in mounted hook - "TypeError: The method setCellphone is not defined in this.$refs.appConfirm"

I encountered an issue while trying to simulate refs in vue. The solution I came across uses stubs, but it seems that stubs only accept strings. it("Testing component", () => { const wrapper = mount(NeedConfirmation, { localVue, stor ...

Displaying Vue v-for data in console.log

One interesting issue arises when printing a list in HTML and checking the output in HTML versus in console.log. It seems that the output is duplicated in the console. After some investigation, I made the following observations: Not showing the product ...

AngularJS using the ng-controller directive

I am presenting the following HTML code excerpt... <!DOCTYPE html> <html lang="en-US" ng-app> <head> <title>priklad00007</title> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angula ...

The table is not visible when using Bootstrap Vue

Can anyone help me with displaying a table of flowers? I am having trouble making it show up on my page. Not quite sure how to use my data to get the flowers to display properly. Any guidance or advice would be greatly appreciated. <b-table> ...

Vue-router error in Quasar SSR application: 'window is not defined'

I am enhancing a Vue app created with Quasar by incorporating ssr functionality. To enable ssr, I utilized the Quasar CLI and executed quasar mode add ssr. This action generated the anticipated src-ssr/ directory along with files. Upon launching the appl ...

Unable to retrieve chosen rows using Angular UI Grid

My scenario involves managing two grids with selectable rows. I aim to retrieve the data from the selected rows and store it in a separate object to send it to a backend service. Here is the relevant code snippet: angular.module('gridPanel',[&ap ...

Building a dynamic web form using JSP and Angular for the JEE platform

I am currently working on a banking project using JSP and angular 1.3.2. I have encountered an issue with a form where, upon blurring after typing the customer number, the customer's information such as name and address should be displayed if the cust ...

Verifying user presence in Vue when making edits

Currently, I'm attempting to validate user existence in Vue using Vuetify inputs when trying to edit a User. The goal is to prevent an error if the username already exists, unless it is the old username of the user being edited without any changes mad ...

Step-by-step guide to implementing a month and year date-picker in Mozilla Firefox

I'm looking to create input fields where users can add the month and year. I tried using the code below, but unfortunately Mozilla Firefox doesn't support it. <input type="month" id="start" name="start"> Does ...

Is it possible to create various HTML elements from JSON data using JQuery?

Is there a way to utilize Jquery and Javascript to extract JSON data from $ajax and then iterate through it using a foreach loop, in order to create a string that can be appended to the HTML DOM? For example: $(document).ready(function (e) { $.ajax({ ...

Creating a PHP script that retrieves data from JavaScript and stores it in MySQL can be accomplished by using AJAX to send the

Hello, I am attempting to create a PHP script that can extract coordinates from this JavaScript code (or from this link ) and store them in a MySQL database. Can someone please provide me with a tutorial on how to accomplish this? <script> var ...

AngularJS - Textarea not resetting content on ng-click event

Having an issue with my textarea. When attempting to clear it using ng-click, nothing happens... Can anyone provide assistance? Here is my code for testing: My app If you prefer to view it here: HTML : <div ng-controller="Ctrl1"> <d ...

modify the material to fit within the specified width

I am facing an issue with my tooltip as the data it displays is overflowing the width of the tooltip. I want to adjust the content to fit within the tooltip width. The tooltip is essentially a badge that shows additional information on hover. I want to set ...

Can you explain the significance of this error message that occurs when attempting to execute a node.js script connected to a MySQL database?

const mysql = require('mysql'); const inquirer = require('inquirer'); const connection = mysql.createConnection({ host: "localhost", port: 8889, user: "root", password: "root", database: "bamazon" }) connection.conn ...