Jest with SharePoint Framework. SyntaxError: Unexpected token export

I’m trying to do tests on an SPFx project with Jest and Enzyme. I have configured the environment using Andrew Connel’s preset to test my solution with React and Typescript.

After run ‘npm test’ I’ve encountered this error on a component that uses Dropdown of Office Fabric UI component:

<mylocalpath>\node_modules\office-ui-fabric-react\lib\components\Dropdown\index.js:1     ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export * from './Dropdown';                                                                                              ^^^^^^      SyntaxError: Unexpected token export 

Can you suggest me the right configuration of Jest for these type of imports?

Uncaught SyntaxError: Unexpected identifier

I’m an artist and i want to make a gallery like in this video. i don’t think that’s the only error so any additional information will be good.

I named the html: test.html

named the css: stylesheet.css

named the javascript: slideshow.js



*{padding: 0; margin: 0; box-sizing: border-box;}

gallery {


width: 500px; height: 500px;


gallery img {

position: absolute; left: 0; top: 0; width: 100%; 



$ (document).ready(function()

$ (“#gallery img:gt(0)”).hide(); <———–THIS IS THE ERROR

$ (“#gallery”).click(function()}

$ (“#gallery img:first”).fadeOut().next().fadeIn().appendTo(“#gallery”)


Error al parsear J SON (SyntaxError: Unexpected token in JSON at position 13033289)

Tengo esta cuestion: necesito leer un archivo JSON y parsearlo, no tuve problema de hacerlo con archivos chicos, pero con uno más extenso me provocó el error mencionado.

Este es mi código:

    var fs = require("fs");      var contents = fs.readFileSync(`/Users/rq-c/Documents/testing-console/src/collections/myjsonfile.json`, `utf-8`)      var jsonArray = JSON.parse(contents) 

Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 REACT

Por qual motivo retorna o erro:

Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0

Estou tentando apenas fazer uma chamada ajax mo meu controller, que na verdade até faz e retorna…

O que eu penso que está acontecendo isso é porque no retorno desta chamada tem um campo que é XML

O que me vem mais uma dúvida, como tratar XML nos componentes do react ?

Segue código:

  plotarCamadaNoMapa(camadas) {         fetch('api/TelaOperadorRJ/GetXMLCamada?idCamada=' + camadas)             .then(response => response.json())             .then(data => {                 this.setState({                     xmlCamada: data                  });             });           console.log(this.state.xmlCamada);          } 

Arquivo que XML:

<kml xmlns="">   <Document>     <Style id="Style1">       <LineStyle>         <color>ff000000</color>         <width>1.2</width>       </LineStyle>       <PolyStyle>         <color>8000ffff</color>         <fill>true</fill>         <outline>true</outline>       </PolyStyle>     </Style>     <Placemark>       <name>Polígono 0</name>       <styleUrl>#Style1</styleUrl>       <Polygon>         <outerBoundaryIs>           <LinearRing>             <coordinates>-46.878889999999998,-23.54439 -46.843359999999997,-23.52 -46.837859999999999,-23.516220000000001 -46.812629999999999,-23.522829999999999 -46.808340000000001,-23.54007 -46.797870000000003,-23.563590000000001 -46.814169999999997,-23.57067 -46.850740000000002,-23.56831 -46.878889999999998,-23.54439</coordinates>           </LinearRing>         </outerBoundaryIs>       </Polygon>     </Placemark>   </Document> </kml> 

Anonymous function in dynamically generated list producing SyntaxError

I want to place an onclick event inside a dynamically generated list. I can’t use it as it is, like updateRoomID(arg), because it would fire immediately. So I placed it inside an anonymous function, as advised by various sources online: function (){updateRoomID(arg)}. But this results in: “Uncaught SyntaxError: Unexpected token (“. Developer tools says the problem is at function().

The section of code it’s in:

socket.onmessage = function(event) {     var msg = JSON.parse(;     for (let i = 0; i < msg.length; i++) {         if (msg[i].beingserved == false) {             listRooms.innerHTML += '<li id=' + msg[i].roomid +                                     // Problem on following line.                                    ' onclick=' + function () { updateRoomID(msg[i].roomid) } +                                     '>' +                                     '<a href="#">' +                                     msg[i].roomid +                                     '</a></li>';         } else {             document.getElementById(msg[i].roomid).remove();         };     }; }; 

I’ve tried placing the onclick handler in href link instead, and also replaced it with addEventListener. But I got the same error. If I try function() {updateRoomID(arg)}() with the parentheses behind, it fires immediately as expected.

I’ve been looking through it all day and can’t figure out where the syntax error is. I’m quite unfamiliar with JavaScript. What am I doing wrong?

The full code if needed:

window.onload = function() {     var listRooms = document.getElementById('room');     var inputRoom = document.getElementById('inputRoom');     var socket = new WebSocket('ws://localhost:8000/clientlistws');      socket.onopen = function(event) {         console.log("Open")     };      socket.onerror = function(error) {         console.log('WebSocket error: ' + error);     };      submitter = function(roomid) {         console.log("submitting: " + roomdid);         document.clientlistForm.inputRoom.value = roomid;         document.getElementById('clientlistForm').submit();     };      updateRoomID = function(roomid) {         document.clientlistForm.inputRoom.value = roomid;         console.log("Updating: " + roomid)     }        socket.onmessage = function(event) {         var msg = JSON.parse(;         for (let i = 0; i < msg.length; i++) {             if (msg[i].beingserved == false) {                 listRooms.innerHTML += '<li id=' + msg[i].roomid + ' onclick=' + function() { updateRoomID(msg[i].roomid) } + '>' +                     '<a href="#">' +                     msg[i].roomid +                     '</a></li>';             } else {                 document.getElementById(msg[i].roomid).remove();             };         };     }; }; 

Erro de um extrator de emails atraves do google PYTHON if page.lower() == “n”: ^ SyntaxError: invalid syntax

Bem estou tentando desenvolver um extrator de emails com python só que esta dando erro:


    import os import mechanize from bs4 import BeautifulSoup import re from urllib import quote import argparse import cookielib from random import randint   def banner():     os.system("clear || cls")     rint('''         ALlan     ''')   def main():     banner()     parser = argparse.ArgumentParser(description='Extract emails')     parser.add_argument('-d', '--dork', metavar='"INSERT DORK"')     parser.add_argument(         '-m', '--mode', help='h/hour, d/day, w/week, m/month, y/year', default="0")     args = parser.parse_args()     if not args.dork:         parser.print_help()         exit()   br = mechanize.Browser()     cj = cookielib.LWPCookieJar() br.set_cookiejar(cj)      #  br.set_handle_equiv(True) br.set_handle_redirect(True) br.set_handle_referer(True) br.set_handle_rebots(False)      # br.set_handle_refresh(mechanize._http.HTTPRefreshPRocessor(), max_time=1)      #  br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')] next_page = 0 print("\n[+] Searching in Google...") while True:     src =""+quote(args.dork)+"&tbs=qdr:%s&start=%s" % (args.mode[0],next_page) ) bs = BeautifulSoup(src.get_data(), 'lxml') for i in bs.find_all('a'):             if "/url?" in i.get('href') and not "" in i.get('href'):                 extract = re.findall(r"q=(.*\.txt)", i.get('href'))                 for link in extract:                     try:                         extract_emails(link,br)                     except:                         continue  page = (raw_input("\n[*] Next page (Y/n)?: ") if page.lower() == "n":     break else:     next_page = next_page+10    def extract_emails(link, br):     src =     print ("[+] Extracting %s" % link)     emails = re.findall(r"[a-zA-Z0-9_.\-]+@[a-zA-Z]+\.[a-z]+\.br", src.get_data())     with open("emails/"+char()+char()+char()+"_emails.txt",'w') as f:             for email in emails:                 f.write(email+"\n") f.close()  def char():             return chr(randint(50,100))  if __name__ == '__main__':         main() 

===================================== Erro: File “”, line 62 if page.lower() == “n”: ^ SyntaxError: invalid syntax