当我尝试在 vue.js 中运行测试用例时,它显示错误本地存储未定义,如何解决此问题请帮助我解决此问题。
[登录.spec.js]
import Login from '../../src/Pages/Login.vue';
import{shallowMount} from '@vue/test-utils';
describe('Login.vue',()=>{
describe('When Loaded',()=>{
it('has the required elements',()=>{
const wrapper =shallowMount(Login);
expect(wrapper.find('#input-username').exists()).toBe(false);
expect(wrapper.find('#input-password').exists()).toBe(false);
});
});
});
[axios.js]
import axios from 'axios'
axios.defaults.baseURL=process.env.VUE_APP_AXIOS_URL
axios.defaults.headers.common['Authorization']='Bearer'+ localStorage.getItem('token');
export default class AxiosService{
postData(url,data){
return axios.post(url,data).then(response =>{
return response;
}).catch(error=>{
return error;
})
}
}